关闭http服务顺序调整

This commit is contained in:
zhucheer 2020-02-02 11:06:03 +08:00
parent dc4976df8a
commit b93221baf3
1 changed files with 6 additions and 7 deletions

View File

@ -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():