1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Fix shutdown server context cancel error

This commit is contained in:
wangsw02
2022-02-11 11:34:17 +08:00
parent aa29174995
commit 6ce4dc97c9

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")
}
}()