health check
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m52s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m52s
This commit is contained in:
25
main.go
25
main.go
@@ -125,7 +125,7 @@ func main() {
|
||||
// if local
|
||||
//syncedPool.AddRemote("localhost")
|
||||
|
||||
_, err = NewGrainHandler(app.pool, ":1337")
|
||||
hg, err := NewGrainHandler(app.pool, ":1337")
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating handler: %v\n", err)
|
||||
}
|
||||
@@ -155,6 +155,29 @@ func main() {
|
||||
mux.HandleFunc("/pprof/symbol", pprof.Symbol)
|
||||
mux.HandleFunc("/pprof/trace", pprof.Trace)
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
|
||||
if !hg.IsHealthy() {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte("handler not healthy"))
|
||||
return
|
||||
}
|
||||
if !syncedPool.IsHealthy() {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte("pool not healthy"))
|
||||
return
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
mux.HandleFunc("/readyz", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
mux.HandleFunc("/livez", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
|
||||
sigs := make(chan os.Signal, 1)
|
||||
done := make(chan bool, 1)
|
||||
|
||||
Reference in New Issue
Block a user