mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-10-04 23:52:53 +08:00
remove proactive health check
This commit is contained in:
@@ -28,7 +28,6 @@ type configuration struct {
|
|||||||
KillWaitTime int `default:"5" describe:"kill信号等待时间(秒)"`
|
KillWaitTime int `default:"5" describe:"kill信号等待时间(秒)"`
|
||||||
TaskTimeout int `default:"60" describe:"任务执行超时时间(秒)"`
|
TaskTimeout int `default:"60" describe:"任务执行超时时间(秒)"`
|
||||||
TokenExpirationTime int64 `default:"720" describe:"token过期时间(小时)"`
|
TokenExpirationTime int64 `default:"720" describe:"token过期时间(小时)"`
|
||||||
WsProactiveHealthCheck bool `default:"false" describe:"ws主动健康检查"`
|
|
||||||
CgroupPeriod int64 `default:"100000" describe:"CgroupPeriod"`
|
CgroupPeriod int64 `default:"100000" describe:"CgroupPeriod"`
|
||||||
CgroupSwapLimit bool `default:"false" describe:"cgroup swap限制"`
|
CgroupSwapLimit bool `default:"false" describe:"cgroup swap限制"`
|
||||||
CondWaitTime int `default:"30" describe:"长轮询等待时间(秒)"`
|
CondWaitTime int `default:"30" describe:"长轮询等待时间(秒)"`
|
||||||
|
@@ -100,31 +100,4 @@ func (w *wsApi) startWsConnect(conn *websocket.Conn, cancel context.CancelFunc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if config.CF.WsProactiveHealthCheck {
|
|
||||||
w.proactiveHealthCheck(conn, cancel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *wsApi) proactiveHealthCheck(conn *websocket.Conn, cancel context.CancelFunc) {
|
|
||||||
pongChan := make(chan struct{})
|
|
||||||
conn.SetPongHandler(func(appData string) error {
|
|
||||||
pongChan <- struct{}{}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
timer := time.NewTimer(time.Second)
|
|
||||||
go func() {
|
|
||||||
defer timer.Stop()
|
|
||||||
for {
|
|
||||||
conn.WriteMessage(websocket.PingMessage, nil)
|
|
||||||
select {
|
|
||||||
case <-pongChan:
|
|
||||||
timer.Reset(time.Second)
|
|
||||||
case <-timer.C:
|
|
||||||
log.Logger.Debugw("pong报文超时,结束ws连接")
|
|
||||||
cancel()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second * 3)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user