Skip to content

Commit

Permalink
Merge pull request #15 from kubuskotak/feat/timeout-shutdown
Browse files Browse the repository at this point in the history
feat: timeout for shutting down
  • Loading branch information
suryakencana007 authored May 7, 2022
2 parents fb8de19 + 187014c commit a1fc934
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ func (s *Server) Quiet(ctx context.Context) {
if err := s.httpServer.Shutdown(ctx); err != nil {
log.Error().Err(err).Msg("Wait is over due to error")
if err = s.httpServer.Close(); err != nil {
log.Error().Err(err)
log.Error().Err(err).Msg("closing failed")
}
}
log.Info().Msgf("Stop server at %s", s.httpServer.Addr)
}

func (s *Server) waitForSignals(ctx context.Context) {
// Do not make the application hang when it is shutdown.
ctxOut, cancel := context.WithTimeout(ctx, time.Second*5)
ctxOut, cancel := context.WithTimeout(ctx, time.Duration(s.TimeOut)*time.Second)
defer cancel()

interrupt := make(chan os.Signal, 1)
Expand Down

0 comments on commit a1fc934

Please sign in to comment.