1、反向下单 暂时提交
This commit is contained in:
@ -86,6 +86,11 @@ func run() error {
|
||||
clearLogJob(db, ctx)
|
||||
})
|
||||
|
||||
//自动重启websocket
|
||||
utility.SafeGo(func() {
|
||||
reconnect(ctx)
|
||||
})
|
||||
|
||||
// 等待中断信号以优雅地关闭服务器(设置 5 秒的超时时间)
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, os.Interrupt)
|
||||
@ -133,3 +138,33 @@ func clearLogJob(db *gorm.DB, ctx context.Context) {
|
||||
fileservice.ClearLogs(db)
|
||||
}
|
||||
}
|
||||
|
||||
// 定时重连websocket
|
||||
func reconnect(ctx context.Context) error {
|
||||
ticker := time.NewTicker(time.Hour * 1)
|
||||
defer ticker.Stop()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-ticker.C:
|
||||
serverinit.RestartConnect()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartDeadCheck 假死检测
|
||||
func StartDeadCheck(ctx context.Context) {
|
||||
ticker := time.NewTicker(1 * time.Minute)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
serverinit.DeadCheck()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user