aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAKP <tom@tdpain.net>2022-04-06 15:23:52 +0100
committerAKP <tom@tdpain.net>2022-04-06 15:23:52 +0100
commitaa87dca0902dfb1cfb6187573fda4b3f2aa8ad99 (patch)
tree6d057e680015dfd8bfc3ee520d5feb3393bdf6b5
parenta0adf349af952c6b8a4f16b046404e1e3ef2c0cf (diff)
Fix worker scheduling issues once and for all (I hope??)
Signed-off-by: AKP <tom@tdpain.net>
-rw-r--r--walrss/internal/rss/watcher.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/walrss/internal/rss/watcher.go b/walrss/internal/rss/watcher.go
index 502b4c1..c29cb69 100644
--- a/walrss/internal/rss/watcher.go
+++ b/walrss/internal/rss/watcher.go
@@ -10,13 +10,21 @@ import (
func StartWatcher(st *state.State) {
go func() {
currentTime := time.Now().UTC()
- time.Sleep(time.Minute * time.Duration(60-currentTime.Minute()))
+
+ timeUntilNextHour := time.Minute * time.Duration(60 - currentTime.Minute())
+ timeUntilNextHour += 30 * time.Second // little bit of buffer time to
+ // make sure we're actually going to be within in the new hour
+
+ time.Sleep(timeUntilNextHour)
runFeedProcessor(st, currentTime)
ticker := time.NewTicker(time.Hour)
- for currentTime := range ticker.C {
- runFeedProcessor(st, currentTime)
+ for range ticker.C {
+ // Yes, I am aware that you can get the current time from ticker.C
+ // BUT that's been weird and caused some issues resulting in an
+ // hour's task not being run, so I'm not using it
+ runFeedProcessor(st, time.Now().UTC())
}
}()
}