mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
添加日志打印
This commit is contained in:
@@ -14,16 +14,23 @@ type Task struct {
|
||||
}
|
||||
|
||||
func (t *Task) Handle() error {
|
||||
log.Infof("received cancel task msg, task_id: %s", t.msg.TaskId)
|
||||
// 取消任务
|
||||
ch := utils.TaskExecChanMap.ChanBlocked(t.msg.TaskId)
|
||||
if ch != nil {
|
||||
ch <- constants.TaskCancel
|
||||
} else {
|
||||
log.Infof("chan is empty, update status to abnormal")
|
||||
// 节点可能被重启,找不到chan
|
||||
t, _ := model.GetTask(t.msg.TaskId)
|
||||
t.Status = constants.StatusCancelled
|
||||
t.FinishTs = time.Now()
|
||||
if err := t.Save(); err != nil {
|
||||
task, err := model.GetTask(t.msg.TaskId)
|
||||
if err != nil {
|
||||
log.Errorf("task not found, task_id: %s", t.msg.TaskId)
|
||||
debug.PrintStack()
|
||||
return err
|
||||
}
|
||||
task.Status = constants.StatusAbnormal
|
||||
task.FinishTs = time.Now()
|
||||
if err := task.Save(); err != nil {
|
||||
debug.PrintStack()
|
||||
log.Infof("cancel task error: %s", err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user