mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13:22:46 +00:00
Track reasons why the process is in a degraded state
This commit is contained in:
parent
a767102f8a
commit
3da182212e
3 changed files with 33 additions and 16 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue