diff --git a/main.go b/main.go index 1fb2957..9202d7e 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,9 @@ type ActionConfig struct { Command *string Args []string + // sleep + Duration *int + Stop bool OnSuccess []ActionConfig `yaml:"onSuccess"` OnError []ActionConfig `yaml:"onError"` @@ -263,6 +266,8 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx) err = actionMail(action, eventInfo, ctx) case "command": err = actionCommand(action, eventInfo, ctx) + case "sleep": + err = actionSleep(action, eventInfo, ctx) default: err = fmt.Errorf("action type %s unknown", action.Type) } @@ -513,6 +518,13 @@ func actionMail(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx) return mail.Send() } +func actionSleep(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx) error { + if action.Duration != nil { + time.Sleep(time.Duration(*action.Duration) * time.Millisecond) + } + return nil +} + func actionCommand(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx) error { if action.Command == nil { return fmt.Errorf("missing command")