diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 990398a84..bdb87e38c 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -15,6 +15,7 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "go_dreamfactory/utils" + "runtime" "github.com/pkg/errors" ) @@ -295,6 +296,14 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T module, err := this.service.GetModule(comm.ModuleWorldtask) if err == nil { go func() { + defer func() { //程序异常 收集异常信息传递给前端显示 + if r := recover(); r != nil { + buf := make([]byte, 4096) + l := runtime.Stack(buf, false) + + log.Errorf("[Handle Api] m:%s ", fmt.Sprintf("%v: %s", r, buf[:l])) + } + }() // 世界任务 if worldtask, ok := module.(comm.IWorldtask); ok { if err := worldtask.TaskcondNotify(session, conf.Id); err != nil { @@ -327,6 +336,13 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T userModule, err := this.service.GetModule(comm.ModuleUser) if err == nil { go func() { + defer func() { //程序异常 收集异常信息传递给前端显示 + if r := recover(); r != nil { + buf := make([]byte, 4096) + l := runtime.Stack(buf, false) + log.Errorf("[Handle Api] m:%s ", fmt.Sprintf("%v: %s", r, buf[:l])) + } + }() // 公会 if user, ok := userModule.(comm.IUser); ok { ex, err := user.GetUserExpand(session.GetUserId()) @@ -345,7 +361,7 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T ) } if module, err := this.service.GetModule(comm.ModuleRtask); err == nil { - if iRtask,ok:=module.(comm.IRtask);ok{ + if iRtask, ok := module.(comm.IRtask); ok { iRtask.SendToRtask(session, comm.Rtype156, 1) } }