From 3fe00996b244886e4a89f3aa4250a391919db106 Mon Sep 17 00:00:00 2001 From: Yuval Yacoby <33892515+yuvalyacoby@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:03:18 +0300 Subject: [PATCH] added healthz endpoint to filer (#4899) --- weed/server/filer_server.go | 1 + weed/server/filer_server_handlers.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index 788ee150a..0f110f1ec 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -157,6 +157,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption) handleStaticResources(defaultMux) if !option.DisableHttp { + defaultMux.HandleFunc("/healthz", fs.filerHealthzHandler) defaultMux.HandleFunc("/", fs.filerHandler) } if defaultMux != readonlyMux { diff --git a/weed/server/filer_server_handlers.go b/weed/server/filer_server_handlers.go index 54ddfb8b2..6bfae3dc1 100644 --- a/weed/server/filer_server_handlers.go +++ b/weed/server/filer_server_handlers.go @@ -179,3 +179,8 @@ func (fs *FilerServer) maybeCheckJwtAuthorization(r *http.Request, isWrite bool) return true } } + +func (fs *FilerServer) filerHealthzHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Server", "SeaweedFS Filer "+util.VERSION) + w.WriteHeader(http.StatusOK) +}