From 9d5edc8ddbc503c757960587f5d7c534650cf1d9 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sun, 31 Dec 2023 12:07:36 +0000 Subject: [PATCH] Add simple liveness endpoint --- cmd/pqlogd/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/pqlogd/main.go b/cmd/pqlogd/main.go index b48eb7c..9336cf9 100644 --- a/cmd/pqlogd/main.go +++ b/cmd/pqlogd/main.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "flag" + "io" "log" "net" "net/http" @@ -47,6 +48,7 @@ func main() { mux := http.NewServeMux() mux.Handle("/metrics", promhttp.Handler()) + mux.HandleFunc("/health", livenessHandler) src, err := uri.Source() if err != nil { @@ -133,6 +135,10 @@ func buildListener() (net.Listener, error) { return l, nil } +func livenessHandler(w http.ResponseWriter, _ *http.Request) { + io.WriteString(w, "OK") // nolint:errcheck +} + // Instrumentation. func instrumentedHandler(h http.Handler, name string, withRequestSize bool) http.Handler { labels := prometheus.Labels{"handler": name} -- GitLab