diff --git a/docs/config/watch.md b/docs/config/watch.md index 58ba16b..8fd2359 100644 --- a/docs/config/watch.md +++ b/docs/config/watch.md @@ -30,7 +30,10 @@ Maximum number of workers that will execute tasks concurrently. (default `10`) ### `schedule` -[CRON expression](https://godoc.org/github.com/robfig/cron#hdr-CRON_Expression_Format) to schedule Diun watcher. (default `0 * * * *`) +[CRON expression](https://godoc.org/github.com/robfig/cron#hdr-CRON_Expression_Format) to schedule Diun. + +!!! warning + Remove this setting if you want to run Diun directly. !!! example "Config file" ```yaml diff --git a/internal/app/diun.go b/internal/app/diun.go index 28edb72..0e18047 100644 --- a/internal/app/diun.go +++ b/internal/app/diun.go @@ -91,7 +91,10 @@ func (di *Diun) Start() error { // Run on startup di.Run() - // Init scheduler + // Init scheduler if defined + if len(di.cfg.Watch.Schedule) == 0 { + return nil + } di.jobID, err = di.cron.AddJob(di.cfg.Watch.Schedule, di) if err != nil { return err diff --git a/internal/model/watch.go b/internal/model/watch.go index 5269ee7..5f98f04 100644 --- a/internal/model/watch.go +++ b/internal/model/watch.go @@ -7,7 +7,7 @@ import ( // Watch holds data necessary for watch configuration type Watch struct { Workers int `yaml:"workers,omitempty" json:"workers,omitempty" validate:"required,min=1"` - Schedule string `yaml:"schedule,omitempty" json:"schedule,omitempty" validate:"required"` + Schedule string `yaml:"schedule,omitempty" json:"schedule,omitempty"` FirstCheckNotif *bool `yaml:"firstCheckNotif,omitempty" json:"firstCheckNotif,omitempty" validate:"required"` CompareDigest *bool `yaml:"compareDigest,omitempty" json:"compareDigest,omitempty" validate:"required"` Healthchecks *Healthchecks `yaml:"healthchecks,omitempty" json:"healthchecks,omitempty"` @@ -23,7 +23,6 @@ func (s *Watch) GetDefaults() *Watch { // SetDefaults sets the default values func (s *Watch) SetDefaults() { s.Workers = 10 - s.Schedule = "0 * * * *" s.FirstCheckNotif = utl.NewFalse() s.CompareDigest = utl.NewTrue() }