sleep action
This commit is contained in:
parent
b3b1ad87b9
commit
b3a90ffc5b
12
main.go
12
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")
|
||||
|
Loading…
Reference in New Issue
Block a user