mirror of
https://github.com/Luzifer/twitch-manager.git
synced 2024-11-09 18:00:05 +00:00
Fix ticker not being triggered properly
This commit is contained in:
parent
37dcf05b87
commit
2d4f0be64b
1 changed files with 13 additions and 7 deletions
28
main.go
28
main.go
|
@ -76,23 +76,29 @@ func main() {
|
|||
log.WithError(err).Fatal("Unable to register webhooks")
|
||||
}
|
||||
|
||||
var (
|
||||
timerForceSync = time.NewTicker(cfg.ForceSyncInterval)
|
||||
timerUpdateFromAPI = time.NewTicker(cfg.UpdateFromAPIInterval)
|
||||
timerWebhookRegister = time.NewTicker(cfg.WebHookTimeout)
|
||||
)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.NewTicker(cfg.WebHookTimeout).C:
|
||||
if err := registerWebHooks(); err != nil {
|
||||
log.WithError(err).Fatal("Unable to re-register webhooks")
|
||||
}
|
||||
|
||||
case <-time.NewTicker(cfg.UpdateFromAPIInterval).C:
|
||||
if err := updateStats(); err != nil {
|
||||
log.WithError(err).Error("Unable to update statistics from API")
|
||||
}
|
||||
|
||||
case <-time.NewTicker(cfg.ForceSyncInterval).C:
|
||||
case <-timerForceSync.C:
|
||||
if err := sendAllSockets(store); err != nil {
|
||||
log.WithError(err).Error("Unable to send store to all sockets")
|
||||
}
|
||||
|
||||
case <-timerUpdateFromAPI.C:
|
||||
if err := updateStats(); err != nil {
|
||||
log.WithError(err).Error("Unable to update statistics from API")
|
||||
}
|
||||
|
||||
case <-timerWebhookRegister.C:
|
||||
if err := registerWebHooks(); err != nil {
|
||||
log.WithError(err).Fatal("Unable to re-register webhooks")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue