ping db in health check

This commit is contained in:
Anton Schubert
2022-07-06 13:39:10 +02:00
parent e0b15c18ce
commit c6aaa37f2d
3 changed files with 51 additions and 13 deletions

14
app.go
View File

@@ -423,19 +423,7 @@ func (h *Headscale) createPrometheusRouter() *gin.Engine {
func (h *Headscale) createRouter(grpcMux *runtime.ServeMux) *mux.Router {
router := mux.NewRouter()
router.HandleFunc(
"/health",
func(writer http.ResponseWriter, req *http.Request) {
writer.WriteHeader(http.StatusOK)
_, err := writer.Write([]byte("{\"healthy\": \"ok\"}"))
if err != nil {
log.Error().
Caller().
Err(err).
Msg("Failed to write response")
}
}).Methods(http.MethodGet)
router.HandleFunc("/health", h.HealthHandler).Methods(http.MethodGet)
router.HandleFunc("/key", h.KeyHandler).Methods(http.MethodGet)
router.HandleFunc("/register", h.RegisterWebAPI).Methods(http.MethodGet)
router.HandleFunc("/machine/{mkey}/map", h.PollNetMapHandler).Methods(http.MethodPost)