From 624131f03ebd120cc752dffb1ec463acf53ccdb7 Mon Sep 17 00:00:00 2001 From: Tordarus Date: Mon, 13 Dec 2021 02:34:19 +0100 Subject: [PATCH] start server in separator go routine --- health.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/health.go b/health.go index 725276b..354cfce 100644 --- a/health.go +++ b/health.go @@ -1,6 +1,7 @@ package dockerhealth import ( + "context" "net/http" ) @@ -12,7 +13,13 @@ var server = &http.Server{ var Healthy bool = true func init() { - server.ListenAndServe() + go func() { + server.ListenAndServe() + }() +} + +func Stop() { + server.Shutdown(context.Background()) } type httpHandler struct {