Merge pull request #703 from quanbisen/master

修复优雅重启不生效
This commit is contained in:
wenjianzhang authored and GitHub committed 2022-09-05 19:56:46 +08:00
commit be1f0be9b2
1 file changed
+3 -2
+3 -2
View File
@@ -113,8 +113,6 @@ func run() error {
}
}
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
go func() {
// 服务连接
@@ -141,6 +139,9 @@ func run() error {
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
<-quit
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
fmt.Printf("%s Shutdown Server ... \r\n", pkg.GetCurrentTimeStr())
if err := srv.Shutdown(ctx); err != nil {