重新规划网关与节点的交互协议,实现统一命令位的识别和处理
This commit is contained in:
@@ -109,24 +109,26 @@ func (s *server) Run() (err error) {
|
||||
}
|
||||
cancel()
|
||||
|
||||
timeout, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
// 主协程退出流程
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
// 报告下线
|
||||
slog.Debug("报告服务下线")
|
||||
err = report.Offline(app.Name)
|
||||
if err != nil {
|
||||
slog.Error("服务下线失败", "err", err)
|
||||
}
|
||||
|
||||
// 报告下线
|
||||
slog.Debug("报告服务下线")
|
||||
err = report.Offline(app.Name)
|
||||
if err != nil {
|
||||
slog.Error("服务下线失败", "err", err)
|
||||
}
|
||||
|
||||
// 关闭 redis
|
||||
g.ExitRedis()
|
||||
// 关闭 redis
|
||||
g.ExitRedis()
|
||||
}()
|
||||
|
||||
// 等待其它服务关闭
|
||||
select {
|
||||
case <-utils.ChanWgWait(timeout, &wg):
|
||||
case <-utils.WgWait(&wg):
|
||||
slog.Info("服务正常关闭")
|
||||
case <-timeout.Done():
|
||||
case <-time.After(time.Duration(env.AppExitTimeout) * time.Second):
|
||||
slog.Warn("超时强制关闭")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user