mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-24 17:41:03 +01:00
fix
This commit is contained in:
@@ -2,7 +2,11 @@ package msg_handler
|
||||
|
||||
import (
|
||||
"crawlab/constants"
|
||||
"crawlab/model"
|
||||
"crawlab/utils"
|
||||
"github.com/apex/log"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
@@ -12,6 +16,17 @@ type Task struct {
|
||||
func (t *Task) Handle() error {
|
||||
// 取消任务
|
||||
ch := utils.TaskExecChanMap.ChanBlocked(t.msg.TaskId)
|
||||
ch <- constants.TaskCancel
|
||||
if ch != nil {
|
||||
ch <- constants.TaskCancel
|
||||
} else {
|
||||
// 节点可能被重启,找不到chan
|
||||
t, _ := model.GetTask(t.msg.TaskId)
|
||||
t.Status = constants.StatusCancelled
|
||||
t.FinishTs = time.Now()
|
||||
if err := t.Save(); err != nil {
|
||||
debug.PrintStack()
|
||||
log.Infof("cancel task error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user