Commit 4a35126b by Daniel Lee

api: health check returns 503 if db is failing

ref #3302
parent f350ae24
......@@ -189,10 +189,12 @@ func (hs *HttpServer) healthHandler(ctx *macaron.Context) {
if err := bus.Dispatch(&models.GetDBHealthQuery{}); err != nil {
data.Set("database", "failing")
}
ctx.Resp.Header().Set("Content-Type", "application/json; charset=UTF-8")
ctx.Resp.WriteHeader(503)
} else {
ctx.Resp.Header().Set("Content-Type", "application/json; charset=UTF-8")
ctx.Resp.WriteHeader(200)
}
dataBytes, _ := data.EncodePretty()
ctx.Resp.Write(dataBytes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment