v1.5.1 增强程序稳定性
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package goman
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -17,6 +18,12 @@ func New(f func()) {
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("[GOMAN]goroutine panic at %s:%d: %v", file, line, r)
|
||||
}
|
||||
}()
|
||||
|
||||
locker.Lock()
|
||||
instanceId++
|
||||
|
||||
@@ -45,6 +52,12 @@ func NewWithArgs(f func(args ...interface{}), args ...interface{}) {
|
||||
_, file, line, _ := runtime.Caller(1)
|
||||
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("[GOMAN]goroutine panic at %s:%d: %v", file, line, r)
|
||||
}
|
||||
}()
|
||||
|
||||
locker.Lock()
|
||||
instanceId++
|
||||
|
||||
|
||||
Reference in New Issue
Block a user