0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-04-10 22:00:13 +00:00

Make scheduler optional ()

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-01-02 16:54:08 +01:00 committed by GitHub
parent 0cab1f8298
commit 072e5d6175
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions
docs/config
internal

View file

@ -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

View file

@ -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

View file

@ -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()
}