mirror of
https://github.com/Luzifer/twitch-manager.git
synced 2024-12-21 04:11:17 +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
20
main.go
20
main.go
|
@ -76,21 +76,27 @@ 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 <-timerForceSync.C:
|
||||
if err := sendAllSockets(store); err != nil {
|
||||
log.WithError(err).Error("Unable to send store to all sockets")
|
||||
}
|
||||
|
||||
case <-time.NewTicker(cfg.UpdateFromAPIInterval).C:
|
||||
case <-timerUpdateFromAPI.C:
|
||||
if err := updateStats(); err != nil {
|
||||
log.WithError(err).Error("Unable to update statistics from API")
|
||||
}
|
||||
|
||||
case <-time.NewTicker(cfg.ForceSyncInterval).C:
|
||||
if err := sendAllSockets(store); err != nil {
|
||||
log.WithError(err).Error("Unable to send store to all sockets")
|
||||
case <-timerWebhookRegister.C:
|
||||
if err := registerWebHooks(); err != nil {
|
||||
log.WithError(err).Fatal("Unable to re-register webhooks")
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue