Fix scheduler

* Delete scheduler history data when scheduler stops

* Fix history trimming bug
This commit is contained in:
Ken Hibino
2021-01-25 22:32:37 -08:00
parent c9a6ab8ae1
commit 6529a1e0b1
3 changed files with 65 additions and 8 deletions

View File

@@ -186,6 +186,7 @@ func (s *Scheduler) Stop() error {
<-ctx.Done()
s.wg.Wait()
s.clearHistory()
s.client.Close()
s.rdb.Close()
s.status.Set(base.StatusStopped)
@@ -237,3 +238,12 @@ func stringifyOptions(opts []Option) []string {
}
return res
}
func (s *Scheduler) clearHistory() {
for _, entry := range s.cron.Entries() {
job := entry.Job.(*enqueueJob)
if err := s.rdb.ClearSchedulerHistory(job.id.String()); err != nil {
s.logger.Warnf("Could not clear scheduler history for entry %q: %v", job.id.String(), err)
}
}
}