execute job function with protection
(id int64, fn TimerFunc)
| 91 | |
| 92 | // execute job function with protection |
| 93 | func safecall(id int64, fn TimerFunc) { |
| 94 | defer func() { |
| 95 | if err := recover(); err != nil { |
| 96 | log.Println(fmt.Sprintf("Handle timer panic: %+v\n%s", err, debug.Stack())) |
| 97 | } |
| 98 | }() |
| 99 | |
| 100 | fn() |
| 101 | } |
| 102 | |
| 103 | func cron() { |
| 104 | if len(timerManager.createdTimer) > 0 { |