mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-06-08 00:42:25 +02:00
Reuse backoff waiting code for errors during GeoIP update.
This commit is contained in:
parent
f6fe960534
commit
a68454ceec
15
hub.go
15
hub.go
|
@ -417,19 +417,20 @@ func (h *Hub) updateGeoDatabase() {
|
||||||
}
|
}
|
||||||
|
|
||||||
defer h.geoipUpdating.Store(false)
|
defer h.geoipUpdating.Store(false)
|
||||||
delay := time.Second
|
backoff, err := NewExponentialBackoff(time.Second, 5*time.Minute)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Could not create exponential backoff: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for !h.closer.IsClosed() {
|
for !h.closer.IsClosed() {
|
||||||
err := h.geoip.Update()
|
err := h.geoip.Update()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Could not update GeoIP database, will retry later (%s)", err)
|
log.Printf("Could not update GeoIP database, will retry in %s (%s)", backoff.NextWait(), err)
|
||||||
time.Sleep(delay)
|
backoff.Wait(context.Background())
|
||||||
delay = delay * 2
|
|
||||||
if delay > 5*time.Minute {
|
|
||||||
delay = 5 * time.Minute
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue