From 4fa8f466752c4d639ca621d79dadcf9f9623396b Mon Sep 17 00:00:00 2001 From: Maksim Paskal Date: Thu, 5 Oct 2023 07:59:51 +0100 Subject: [PATCH] fix web server shutdown message (#181) Signed-off-by: Maksim Paskal --- cmd/main/main.go | 4 ++-- pkg/web/web.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/main/main.go b/cmd/main/main.go index 30da101..7c19780 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -136,8 +136,6 @@ func main() { go RunLeaderElection(ctx) } - go web.StartServer(ctx) - go func() { select { case <-signalChanInterrupt: @@ -156,6 +154,8 @@ func main() { time.Sleep(config.Get().GetGracefulShutdown()) }) + go web.StartServer(ctx) + <-ctx.Done() log.Info("Shutting down...") diff --git a/pkg/web/web.go b/pkg/web/web.go index 7e03080..3864c9c 100644 --- a/pkg/web/web.go +++ b/pkg/web/web.go @@ -137,7 +137,7 @@ func StartServer(ctx context.Context) { _ = server.Shutdown(ctx) //nolint:contextcheck }() - if err := server.ListenAndServe(); err != nil && ctx.Err() != nil { + if err := server.ListenAndServe(); err != nil && ctx.Err() == nil { log.WithError(err).Fatal() } }