Skip to content

Commit

Permalink
chore: 补充日志信息
Browse files Browse the repository at this point in the history
  • Loading branch information
twbworld committed Nov 8, 2023
1 parent 234bbb1 commit 0e14b58
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion initialize/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ func Init() {
if err != nil {
global.Log.Fatalln("打开文件错误: ", err)
}
gin.DefaultWriter = io.MultiWriter(ginfile)
gin.DefaultWriter = io.MultiWriter(ginfile) //记录所有日志
gin.DefaultErrorWriter = global.Log.Out

mode := gin.ReleaseMode
if global.Config.Env.Debug {
Expand Down Expand Up @@ -58,8 +59,11 @@ func Init() {
service.TgSend("启动成功")

<-ctx.Done() //阻塞等待

//来到这 证明有关闭指令,将进行平滑优雅关闭服务

global.Log.Infof("程序关闭中..., port: %s, pid: %d", global.Config.AppConfig.GinAddr, syscall.Getpid())

stop()

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) //如果有连接就超时5s后关闭
Expand Down

0 comments on commit 0e14b58

Please sign in to comment.