~bigbes/core-go

ff38670c315a701365f5c9aad1554fcb7e2d7c9f — Conrad Hoffmann 3 months ago 7f734c7
server: add health endpoint to metrics listener

There are already facilities to run the metrics listener on a fixed
port, so this makes for a useful endpoint to have metrics and a health
check in Kubernetes without exposing them to the world. In the long run,
I would like to remove the metrics endpoint from the public listener,
but that will take more work.
1 files changed, 3 insertions(+), 0 deletions(-)

M server/server.go
M server/server.go => server/server.go +3 -0
@@ 438,6 438,9 @@ func (server *Server) Run() {

	mux := &http.ServeMux{}
	mux.Handle("/metrics", promhttp.Handler())
	mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("OK"))
	})
	pserver := &http.Server{Handler: mux}
	plisten, err := net.Listen("tcp", server.metricsAddr)
	if err != nil {