From b93221baf30382cff30a1e594a0b6feac160e243 Mon Sep 17 00:00:00 2001 From: zhucheer Date: Sun, 2 Feb 2020 11:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=ADhttp=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/shutdown.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/shutdown.go b/app/shutdown.go index 226f695..c8095e0 100644 --- a/app/shutdown.go +++ b/app/shutdown.go @@ -76,11 +76,11 @@ func listenShutDownSign(ctx context.Context, httpSrv *http.Server){ // 发送应用退出信号 sendAppStop() - // 关闭http服务 - httpSrv.Shutdown(ctx) - //处理后置操作等待结束 appDeferDo(ctx) + + // 关闭http服务 + httpSrv.Shutdown(ctx) } } @@ -88,9 +88,9 @@ func listenShutDownSign(ctx context.Context, httpSrv *http.Server){ func sendAppStop(){ for _,stopSigItem:=range exitWaitHandler.stopSignList{ - go func(sig chan StopSignal) { - sig<-StopSignal(1) - }(stopSigItem) + go func(sig chan StopSignal) { + sig<-StopSignal(1) + }(stopSigItem) } } @@ -101,7 +101,6 @@ func appDeferDo(ctx context.Context){ if maxTimeout == 0{ maxTimeout = 90 } - maxTimeoutContext,_:= context.WithTimeout(ctx, time.Duration(maxTimeout)*time.Second) select{ case <-maxTimeoutContext.Done():