start server in separator go routine

This commit is contained in:
Tordarus 2021-12-13 02:34:19 +01:00
parent b680ac3460
commit 624131f03e

View File

@ -1,6 +1,7 @@
package dockerhealth package dockerhealth
import ( import (
"context"
"net/http" "net/http"
) )
@ -12,7 +13,13 @@ var server = &http.Server{
var Healthy bool = true var Healthy bool = true
func init() { func init() {
go func() {
server.ListenAndServe() server.ListenAndServe()
}()
}
func Stop() {
server.Shutdown(context.Background())
} }
type httpHandler struct { type httpHandler struct {