``` feat(socket): 优化panic处理逻辑并添加详细堆栈打印,完善服务器退出条件检查

This commit is contained in:
1
2025-10-28 07:39:11 +00:00
parent ec082db71d
commit a37b459793
5 changed files with 27 additions and 18 deletions

View File

@@ -8,7 +8,9 @@ import (
"blazing/common/utils/bytearray"
"blazing/cool"
"fmt"
"log"
"math/rand"
"runtime/debug"
"strings"
"blazing/logic/service/common"
@@ -90,7 +92,14 @@ type eventHandler struct {
}
func (h *eventHandler) OnEvent(v []byte) {
defer func() {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
log.Printf("捕获到 panic 错误:%v", err)
// 2. 打印完整调用堆栈debug.Stack() 获取堆栈字节流,转为字符串)
log.Printf("panic 详细堆栈:\n%s", debug.Stack())
}
}()
header := TomeeHeader{}
tempdata := bytearray.CreateByteArray(v)