diff --git a/cmd/inbound/inbound.go b/cmd/inbound/inbound.go index 6cfe6e2..7cce17d 100644 --- a/cmd/inbound/inbound.go +++ b/cmd/inbound/inbound.go @@ -108,6 +108,8 @@ func main() { s.MaxRecipients = 10 s.AuthDisabled = true + defer s.Close() // nolint:errcheck + log.Info("starting health service") go runHealthService(cm) @@ -126,7 +128,17 @@ func main() { }() } - log.Fatal("server exited", zap.Error(s.ListenAndServe())) + go func() { + defer cancel() + + if err := s.ListenAndServe(); err != nil { + log.Error("listener failed", zap.Error(err)) + } + }() + + <-ctx.Done() + + log.Info("exiting") } func runHealthService(cm *localtls.CertManager) {