修复:weblive 协程 panic 防护、Mongo 空指针防护、直播状态轮询退避

Made-with: Cursor
This commit is contained in:
whm
2026-03-25 16:45:22 +08:00
parent 70e6782713
commit 7e24a965bc
6 changed files with 70 additions and 12 deletions

View File

@@ -0,0 +1,15 @@
package weblive
import "log"
// goSafe 在独立 goroutine 中运行 fnpanic 只记录日志,避免拖垮整个 HTTP 进程(否则 Nginx 会看到 502
func goSafe(label string, fn func()) {
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("weblive: panic in %s: %v", label, r)
}
}()
fn()
}()
}