Handle panic debug on the Satan side
This commit is contained in:
parent
182cfa3e40
commit
d2041b69a1
10
daemon.go
10
daemon.go
|
@ -172,16 +172,8 @@ func (d *BaseDaemon) base() *BaseDaemon {
|
|||
return d
|
||||
}
|
||||
|
||||
func (d *BaseDaemon) handlePanic() {
|
||||
err := recover()
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
d.stats.registerError()
|
||||
func (d *BaseDaemon) handlePanic(err interface{}) {
|
||||
if d.panicHandler != nil {
|
||||
d.panicHandler(err)
|
||||
}
|
||||
log.Printf("Daemon %s recovered from a panic\nError: %v\n", d, err)
|
||||
debug.PrintStack()
|
||||
}
|
||||
|
|
8
satan.go
8
satan.go
|
@ -169,11 +169,17 @@ func (s *Satan) processSystemTask(t *task) {
|
|||
}
|
||||
|
||||
func (s *Satan) processGeneralTask(t *task) {
|
||||
defer t.daemon.base().handlePanic()
|
||||
defer func(start time.Time) {
|
||||
dur := time.Now().UnixNano() - start.UnixNano()
|
||||
t.daemon.base().stats.add(time.Duration(dur))
|
||||
}(time.Now())
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
t.daemon.base().handlePanic(err)
|
||||
log.Printf("Daemon %s recovered from a panic\nError: %v\n", t.daemon.base(), err)
|
||||
debug.PrintStack()
|
||||
}
|
||||
}()
|
||||
|
||||
t.actor() // <--- THE ACTION HAPPENS HERE
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue