internal: fix high cpu when backend isnt healthy
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
254249e38b
commit
eb6cfd22a7
|
@ -83,14 +83,20 @@ func (g *GoUnicorn) healthcheck() {
|
||||||
|
|
||||||
// Default healthcheck is every 1 second on startup
|
// Default healthcheck is every 1 second on startup
|
||||||
// once we've been healthy once, increase to 30 seconds
|
// once we've been healthy once, increase to 30 seconds
|
||||||
for range time.Tick(time.Second) {
|
func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-time.Tick(1 * time.Second):
|
||||||
if check() {
|
if check() {
|
||||||
g.log.Info("backend is alive, backing off with healthchecks")
|
g.log.Info("backend is alive, backing off with healthchecks")
|
||||||
g.HealthyCallback()
|
g.HealthyCallback()
|
||||||
break
|
return
|
||||||
}
|
} else {
|
||||||
g.log.Debug("backend not alive yet")
|
g.log.Debug("backend not alive yet")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
for range time.Tick(30 * time.Second) {
|
for range time.Tick(30 * time.Second) {
|
||||||
check()
|
check()
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue