From 26adf3f774f172a7ef1da1defa64f713420bd7b5 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 15 Oct 2022 11:54:11 +0200 Subject: [PATCH] cmd: always stop gunicorn before exiting Signed-off-by: Jens Langhammer --- cmd/server/main.go | 8 +++++--- internal/gounicorn/gounicorn.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index a013af2e0..d650f87ea 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -58,7 +58,11 @@ func main() { u, _ := url.Parse("http://localhost:8000") - g := gounicorn.NewGoUnicorn() + g := gounicorn.New() + defer func() { + l.Info("shutting down gunicorn") + g.Kill() + }() ws := web.NewWebServer(g) g.HealthyCallback = func() { if !config.Get().Outposts.DisableEmbeddedOutpost { @@ -70,8 +74,6 @@ func main() { ws.Start() <-ex running = false - l.Info("shutting down gunicorn") - go g.Kill() l.Info("shutting down webserver") go ws.Shutdown() } diff --git a/internal/gounicorn/gounicorn.go b/internal/gounicorn/gounicorn.go index 4f593550a..5cf65a733 100644 --- a/internal/gounicorn/gounicorn.go +++ b/internal/gounicorn/gounicorn.go @@ -23,7 +23,7 @@ type GoUnicorn struct { alive bool } -func NewGoUnicorn() *GoUnicorn { +func New() *GoUnicorn { logger := log.WithField("logger", "authentik.router.unicorn") g := &GoUnicorn{ log: logger,