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
|
Command *string
|
||||||
Args []string
|
Args []string
|
||||||
|
|
||||||
|
// sleep
|
||||||
|
Duration *int
|
||||||
|
|
||||||
Stop bool
|
Stop bool
|
||||||
OnSuccess []ActionConfig `yaml:"onSuccess"`
|
OnSuccess []ActionConfig `yaml:"onSuccess"`
|
||||||
OnError []ActionConfig `yaml:"onError"`
|
OnError []ActionConfig `yaml:"onError"`
|
||||||
@ -263,6 +266,8 @@ func runAction(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx)
|
|||||||
err = actionMail(action, eventInfo, ctx)
|
err = actionMail(action, eventInfo, ctx)
|
||||||
case "command":
|
case "command":
|
||||||
err = actionCommand(action, eventInfo, ctx)
|
err = actionCommand(action, eventInfo, ctx)
|
||||||
|
case "sleep":
|
||||||
|
err = actionSleep(action, eventInfo, ctx)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("action type %s unknown", action.Type)
|
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()
|
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 {
|
func actionCommand(action *ActionConfig, eventInfo notify.EventInfo, ctx actionCtx) error {
|
||||||
if action.Command == nil {
|
if action.Command == nil {
|
||||||
return fmt.Errorf("missing command")
|
return fmt.Errorf("missing command")
|
||||||
|
Loading…
Reference in New Issue
Block a user