diff --git a/cron.go b/cron.go index d59f9fe..7bd2ddd 100644 --- a/cron.go +++ b/cron.go @@ -7,6 +7,7 @@ import "context" // tasks on time intervals. type cron struct { trimFunc func() bool + fastTiming bool timing struct { trimInterval time.Duration } @@ -28,6 +29,9 @@ func (this *cron) Configure (config Config) error { } this.timing.trimInterval = value } + if this.fastTiming { + this.timing.trimInterval = time.Second * 10 + } return nil } diff --git a/environment.go b/environment.go index 50cca69..bd138de 100644 --- a/environment.go +++ b/environment.go @@ -33,6 +33,7 @@ type environment struct { done context.CancelCauseFunc group sync.WaitGroup conf MutableConfig + cron *cron // flags stores information from built-in flags. flags struct { @@ -81,10 +82,11 @@ func (this *environment) Run(name, description string, actors ...Actor) { this.name = name this.description = description this.actors = usync.NewRWMonitor(&actorSets { }) - this.addToSets(actors...) - this.addToSets(&cron { + this.cron = &cron { trimFunc: this.phase70_5Trimming, - }) + } + this.addToSets(actors...) + this.addToSets(this.cron) if !this.phase10FlagParsing() { os.Exit(2) } if !this.phase13PidFileCreation() { os.Exit(1) } @@ -438,8 +440,7 @@ func (this *environment) applyConfig() error { if err != nil { return err } if this.flags.fastTiming { - this.timing.shutdownTimeout.Store(this.timing.shutdownTimeout.Load() / 60) - // TODO: quicken trim interval + this.timing.shutdownTimeout.Store(time.Second * 10) } return nil diff --git a/phases.go b/phases.go index 0fd87c3..7e3dd2a 100644 --- a/phases.go +++ b/phases.go @@ -73,6 +73,7 @@ func (this *environment) phase10FlagParsing() bool { } if _, ok := flagFastTiming.First(); ok { this.flags.fastTiming = true + this.cron.fastTiming = true } return true }