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,