mirror of
https://github.com/crazy-max/diun.git
synced 2025-04-10 22:00:13 +00:00
Make scheduler optional (#251)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
0cab1f8298
commit
072e5d6175
3 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue