From 19873db1a9c08e7365b255c0117a00e120392bb7 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Tue, 27 Feb 2024 18:55:09 +0100 Subject: [PATCH] add comment and adjust log position --- management/server/scheduler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/management/server/scheduler.go b/management/server/scheduler.go index ba3d03fc0..c6a5da539 100644 --- a/management/server/scheduler.go +++ b/management/server/scheduler.go @@ -103,15 +103,16 @@ func (wm *DefaultScheduler) Schedule(in time.Duration, ID string, job func() (ne ticker.Stop() return } - if runIn != in { // do we need to compare it with the original duration? + // we need this comparison to avoid resetting the ticker with the same duration and missing the current elapsesed time + if runIn != in { ticker.Reset(runIn) } case <-cancel: ticker.Stop() - log.Debugf("stopped scheduled job %s ", ID) wm.mu.Lock() defer wm.mu.Unlock() delete(wm.jobs, ID) + log.Debugf("stopped scheduled job %s ", ID) return } }