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() {
|
||||||
if check() {
|
for {
|
||||||
g.log.Info("backend is alive, backing off with healthchecks")
|
select {
|
||||||
g.HealthyCallback()
|
case <-time.Tick(1 * time.Second):
|
||||||
break
|
if check() {
|
||||||
|
g.log.Info("backend is alive, backing off with healthchecks")
|
||||||
|
g.HealthyCallback()
|
||||||
|
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 a new issue