Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
27 lines
581 B
Go
27 lines
581 B
Go
package godef
|
|
|
|
import (
|
|
"runtime"
|
|
"videoweb/pub/common/log"
|
|
"videoweb/pub/common/tgbot"
|
|
)
|
|
|
|
func Go(f func()) {
|
|
//atomic.AddInt64(&routineCount, 1)
|
|
go func() {
|
|
defer func() {
|
|
//atomic.AddInt64(&routineCount, -1)
|
|
if r := recover(); r != nil {
|
|
buf := make([]byte, 2048)
|
|
length := runtime.Stack(buf, false)
|
|
info := string(buf[:length])
|
|
log.Error("cat a unkown excetion", log.Any("excetion :", info), log.Any("e", r))
|
|
//发送tg消息
|
|
msg := "goroutine crash,the stack:\n" + info
|
|
tgbot.SendToProgram("程序异常", msg)
|
|
}
|
|
}()
|
|
f()
|
|
}()
|
|
}
|