mirror of
https://github.com/hibiken/asynq.git
synced 2025-09-19 05:17:30 +08:00
Fix scheduler
* Delete scheduler history data when scheduler stops * Fix history trimming bug
This commit is contained in:
10
scheduler.go
10
scheduler.go
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user