Skip to content

Commit

Permalink
Update task.go
Browse files Browse the repository at this point in the history
  • Loading branch information
rushuinet committed Sep 9, 2020
1 parent ff29d38 commit 6cf9b46
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"
"log"
"runtime/debug"
"runtime"
)

//任务执行函数
Expand All @@ -27,7 +27,8 @@ func (t *Task) Run(callback func(code int64, msg string)) {
defer func(cancel func()) {
if err := recover(); err != nil {
log.Println(t.Info()+" panic: ", err)
debug.PrintStack() //堆栈跟踪
_, file, line, _ := runtime.Caller(2)
log.Printf("panic file %s:%d", file, line) //堆栈跟踪
callback(500, "task panic:"+fmt.Sprintf("%v", err))
cancel()
}
Expand Down

0 comments on commit 6cf9b46

Please sign in to comment.