Revert "优化服务退出流程,增加中间件文档"

This reverts commit c511a2e6b3.
This commit is contained in:
maxbad
2023-05-15 23:15:17 +08:00
parent c981d0b8eb
commit 64ed43b7ca
30 changed files with 98 additions and 336 deletions

View File

@@ -10,11 +10,13 @@ import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcmd"
"hotgo/internal/crons"
"hotgo/internal/library/addons"
"hotgo/internal/library/casbin"
"hotgo/internal/router"
"hotgo/internal/service"
"hotgo/internal/websocket"
"os"
)
var (
@@ -75,20 +77,13 @@ var (
// https
setSSL(ctx, s)
serverWg.Add(1)
// 信号监听
signalListen(ctx, signalHandlerForOverall)
go func() {
select {
case <-serverCloseSignal:
websocket.Stop()
service.TCPServer().Stop(ctx)
s.Shutdown() // 主服务建议放在最后一个关闭
g.Log().Debug(ctx, "http successfully closed ..")
serverWg.Done()
}
}()
// 退出信号监听
signalListen(ctx, func(sig os.Signal) {
s.Shutdown()
crons.StopALL()
websocket.Stop()
service.TCPServer().Stop(ctx)
})
// Just run the server.
s.Run()