Merge pull request #281 from laraws/hotfix/fix-shutdown-server-error

Fix shutdown server context cancel error
This commit is contained in:
Maksym Pavlenko
2022-02-11 14:23:27 -08:00
committed by GitHub
+5 -1
View File
@@ -190,8 +190,12 @@ func main() {
group.Go(func() error {
// Shutdown web server
defer func() {
ctxShutDown, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer func() {
cancel()
}()
log.Info("shutting down web server")
if err := srv.Shutdown(ctx); err != nil {
if err := srv.Shutdown(ctxShutDown); err != nil {
log.WithError(err).Error("server shutdown failed")
}
}()