From a668fdb29986843e680858ad1140b661eb35448f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Carpintero?= Date: Wed, 18 Dec 2024 19:22:26 +0100 Subject: [PATCH] fix shuttedDown --- internal/http/check.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/internal/http/check.go b/internal/http/check.go index c0cc9c8..1ad85bd 100644 --- a/internal/http/check.go +++ b/internal/http/check.go @@ -125,7 +125,6 @@ func (c *Check) RunAndServe() { }) http.HandleFunc("/run", c.ServeHTTP) c.Logger.Info(fmt.Sprintf("Listening at %s", c.server.Addr)) - c.shuttedDown = make(chan int) go func() { if err := c.server.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) { c.Logger.WithError(err).Error("Starting http server") @@ -168,12 +167,11 @@ func (c *Check) Shutdown() error { // Send the exit signal to shutdown the server. c.exitSignal <- syscall.SIGTERM - if c.shuttedDown != nil { - // Wait for the server to shutdown. - c.Logger.Info("Shutdown: waiting for shuttedDown") - <-c.shuttedDown - c.Logger.Info("Shutdown:shutted down") - } + c.shuttedDown = make(chan int) + // Wait for the server to shutdown. + c.Logger.Info("Shutdown: waiting for shuttedDown") + <-c.shuttedDown + c.Logger.Info("Shutdown:shutted down") return nil }