Skip to content

Commit

Permalink
api: health check returns 503 if db is failing
Browse files Browse the repository at this point in the history
ref #3302
  • Loading branch information
daniellee committed May 10, 2017
1 parent f350ae2 commit 4a35126
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/api/http_server.go
Expand Up @@ -189,11 +189,13 @@ 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)
}

ctx.Resp.Header().Set("Content-Type", "application/json; charset=UTF-8")
ctx.Resp.WriteHeader(200)

dataBytes, _ := data.EncodePretty()
ctx.Resp.Write(dataBytes)
}
Expand Down

0 comments on commit 4a35126

Please sign in to comment.