From e6f4fac859e609e0b745f05da5fb56431130cc03 Mon Sep 17 00:00:00 2001 From: quanbisen <1769128867@qq.com> Date: Wed, 31 Aug 2022 18:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=98=E9=9B=85=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/api/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/api/server.go b/cmd/api/server.go index 0a274fe4..f515ffbb 100644 --- a/cmd/api/server.go +++ b/cmd/api/server.go @@ -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 {