fix: 解决容器执行 exit 退出后服务 panic 的问题

This commit is contained in:
ssonglius11 2024-05-08 16:43:00 +08:00
parent a6f354fed9
commit 5ed703f7c3
2 changed files with 10 additions and 0 deletions

View file

@ -70,6 +70,11 @@ func (sws *LocalWsSession) masterWrite(data []byte) error {
}
func (sws *LocalWsSession) receiveWsMsg(exitCh chan bool) {
defer func() {
if r := recover(); r != nil {
global.LOG.Errorf("[xpack] A panic occurred during receive ws message, error message: %v", r)
}
}()
wsConn := sws.wsConn
defer setQuit(exitCh)
defer global.LOG.Debug("thread of receive ws msg has exited now")

View file

@ -116,6 +116,11 @@ func (sws *LogicSshWsSession) Start(quitChan chan bool) {
}
func (sws *LogicSshWsSession) receiveWsMsg(exitCh chan bool) {
defer func() {
if r := recover(); r != nil {
global.LOG.Errorf("[xpack] A panic occurred during receive ws message, error message: %v", r)
}
}()
wsConn := sws.wsConn
defer setQuit(exitCh)
for {