1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 18:10:48 +00:00

call cancel after shutdown

This commit is contained in:
nuczzz 2019-01-18 19:33:45 +08:00
parent 7173fd7490
commit 313be996cd

View File

@ -268,7 +268,9 @@ func (srv *Server) shutdown() {
log.Println(syscall.Getpid(), "Waiting for connections to finish...")
ctx := context.Background()
if DefaultTimeout >= 0 {
ctx, _ = context.WithTimeout(context.Background(), DefaultTimeout)
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(context.Background(), DefaultTimeout)
defer cancel()
}
srv.terminalChan <- srv.Server.Shutdown(ctx)
}