diff --git a/cmd/serve/http/http.go b/cmd/serve/http/http.go index dab1489d7..592580826 100644 --- a/cmd/serve/http/http.go +++ b/cmd/serve/http/http.go @@ -69,6 +69,7 @@ control the stats printing. return err } s.Bind(router) + httplib.Wait() return nil }) }, diff --git a/lib/http/http.go b/lib/http/http.go index 61525bab4..28c2596d7 100644 --- a/lib/http/http.go +++ b/lib/http/http.go @@ -231,6 +231,11 @@ func (s *server) Serve() { } } +// Wait blocks while the server is serving requests +func (s *server) Wait() { + s.closing.Wait() +} + // Router returns the server base router func (s *server) Router() chi.Router { return s.baseRouter @@ -291,6 +296,11 @@ func Restart() error { return start() } +// Wait blocks while the default http server is serving requests +func Wait() { + defaultServer.Wait() +} + // Start the default server func start() error { defaultServerMutex.Lock()