Skip to content

Commit

Permalink
fix shuttedDown
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusfcr committed Dec 18, 2024
1 parent 8f50a26 commit a668fdb
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/http/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit a668fdb

Please sign in to comment.