diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-10-04 13:02:41 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-10-04 13:02:41 +0100 |
commit | 3da182212e86daca1d7019efbd424b2bd38b8b3c (patch) | |
tree | 3d3e4b7d52e03f69aa352aa57f04f904160c71bb /setup/base | |
parent | a767102f8a74031b5d0612d985c7589dfe0e0821 (diff) |
Track reasons why the process is in a degraded state
Diffstat (limited to 'setup/base')
-rw-r--r-- | setup/base/base.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/setup/base/base.go b/setup/base/base.go index 0636c7b8..2e3a3a19 100644 --- a/setup/base/base.go +++ b/setup/base/base.go @@ -18,6 +18,7 @@ import ( "context" "crypto/tls" "database/sql" + "encoding/json" "fmt" "io" "net" @@ -467,8 +468,13 @@ func (b *BaseDendrite) SetupAndServeHTTP( w.WriteHeader(200) }) b.DendriteAdminMux.HandleFunc("/monitor/health", func(w http.ResponseWriter, r *http.Request) { - if b.ProcessContext.IsDegraded() { + if isDegraded, reasons := b.ProcessContext.IsDegraded(); isDegraded { w.WriteHeader(503) + _ = json.NewEncoder(w).Encode(struct { + Warnings []string `json:"warnings"` + }{ + Warnings: reasons, + }) return } w.WriteHeader(200) |