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

This commit is contained in:
ssongliu 2024-05-08 17:38:24 +08:00 committed by GitHub
parent d7df881da9
commit 1e192c18e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 {