From af45a42d8cc970a541ad66f5c85ead01b6cbde30 Mon Sep 17 00:00:00 2001 From: AKP Date: Wed, 6 Apr 2022 19:24:08 +0100 Subject: Fix first hourly job running for the wrong hour Signed-off-by: AKP --- walrss/internal/rss/watcher.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/walrss/internal/rss/watcher.go b/walrss/internal/rss/watcher.go index f832c12..62f12af 100644 --- a/walrss/internal/rss/watcher.go +++ b/walrss/internal/rss/watcher.go @@ -10,9 +10,7 @@ import ( func StartWatcher(st *state.State) { log.Debug().Str("location", "feed watcher").Msg("starting feed watcher") go func() { - currentTime := time.Now().UTC() - - timeUntilNextHour := time.Minute * time.Duration(60-currentTime.Minute()) + timeUntilNextHour := time.Minute * time.Duration(60-time.Now().UTC().Minute()) timeUntilNextHour += 30 * time.Second // little bit of buffer time to // make sure we're actually going to be within in the new hour @@ -20,7 +18,7 @@ func StartWatcher(st *state.State) { time.Sleep(timeUntilNextHour) - runFeedProcessor(st, currentTime) + runFeedProcessor(st, time.Now().UTC()) log.Debug().Str("location", "feed watcher").Msg("starting ticker") -- cgit v1.2.3-70-g09d2