示例#1
0
// Run stops the execution if the another execution is already running
func (m *Overlap) Run(ctx *core.Context) error {
	if m.NoOverlap && ctx.Job.Running() > 1 {
		ctx.Stop(core.ErrSkippedExecution)
	}

	return ctx.Next()
}
示例#2
0
文件: slack.go 项目: ivanfoo/ofelia
// Run sends a message to the slack channel, its close stop the exection to
// collect the metrics
func (m *Slack) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.SlackOnlyOnError {
		m.pushMessage(ctx)
	}

	return err
}
示例#3
0
文件: save.go 项目: mcuadros/ofelia
// Run save the result of the execution to disk
func (m *Save) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.SaveOnlyOnError {
		err := m.saveToDisk(ctx)
		if err != nil {
			ctx.Logger.Errorf("Save error: %q", err)
		}
	}

	return err
}
示例#4
0
文件: mail.go 项目: ivanfoo/ofelia
// Run sents a email with the result of the execution
func (m *Mail) Run(ctx *core.Context) error {
	err := ctx.Next()
	ctx.Stop(err)

	if ctx.Execution.Failed || !m.MailOnlyOnError {
		err := m.sendMail(ctx)
		if err != nil {
			ctx.Logger.Error("Mail error: %q", err)
		}
	}

	return err
}