From 4a2e43ecf26385aff611a548182743e3dd27b8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Sat, 30 Sep 2023 17:02:49 -0400 Subject: [PATCH] add health service --- cmd/inbound/inbound.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/inbound/inbound.go b/cmd/inbound/inbound.go index 1d69574..e10a693 100644 --- a/cmd/inbound/inbound.go +++ b/cmd/inbound/inbound.go @@ -5,6 +5,8 @@ import ( "crypto/tls" "encoding/json" "flag" + "fmt" + "net/http" "os" "os/signal" "syscall" @@ -93,5 +95,15 @@ func main() { GetCertificate: cm.Get, } + go runHealthService() + log.Fatal("server exited", zap.Error(s.ListenAndServeTLS())) } + +func runHealthService() { + http.HandleFunc("/health", func(w http.ResponseWriter, req *http.Request) { + w.Write([]byte("OK")) //nolint:errcheck + }) + + http.ListenAndServe(fmt.Sprintf(":%d", healthPort), nil) //nolint:errcheck +}