Revert "internal: fix high cpu when backend isnt healthy"
This reverts commiteb6cfd22a7
. Revert "root: handle JSON error in metrics too" This reverts commit1ede972222
. Revert "root: don't force multiprocess prometheus registry" This reverts commitcd1d1b4402
. Revert "root: add error handling for prometheus view" This reverts commitc0a883f76f
.
This commit is contained in:
parent
1ede972222
commit
84930b4924
|
@ -1,6 +1,5 @@
|
||||||
"""Metrics view"""
|
"""Metrics view"""
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from json import JSONDecodeError
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connections
|
from django.db import connections
|
||||||
|
@ -32,10 +31,7 @@ class MetricsView(View):
|
||||||
|
|
||||||
monitoring_set.send_robust(self)
|
monitoring_set.send_robust(self)
|
||||||
|
|
||||||
try:
|
|
||||||
return ExportToDjangoView(request)
|
return ExportToDjangoView(request)
|
||||||
except (UnicodeDecodeError, KeyError, ValueError, JSONDecodeError):
|
|
||||||
return HttpResponse(status_code=500)
|
|
||||||
|
|
||||||
|
|
||||||
class LiveView(View):
|
class LiveView(View):
|
||||||
|
|
|
@ -83,20 +83,14 @@ 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
|
||||||
func() {
|
for range time.Tick(time.Second) {
|
||||||
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()
|
||||||
return
|
break
|
||||||
} 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