Browse Source

improve task save fail and crap fail logic

master
filesite 7 months ago
parent
commit
f03a296db6
  1. 16
      lib/taskMoniter.mjs
  2. 2
      spider.mjs

16
lib/taskMoniter.mjs

@ -95,6 +95,18 @@ class TaskMoniter { @@ -95,6 +95,18 @@ class TaskMoniter {
return true;
}
setTaskWaiting(task_id) {
if (typeof(this.tasks[task_id]) == 'undefined') {
return false;
}
this.taskStatus[this.tasks[task_id].status] --;
this.taskStatus[this.statusCode.waiting] ++;
this.tasks[task_id].status = this.statusCode.waiting;
return true;
}
setTaskDone(task_id) {
if (typeof(this.tasks[task_id]) == 'undefined') {
return false;
@ -243,8 +255,8 @@ class TaskMoniter { @@ -243,8 +255,8 @@ class TaskMoniter {
console.log("[%s][%s] Task %s's data save to HeroUnion done",
common.getTimeString(), task.notify_time, task.id);
}else {
console.log("[%s][%s] Task %s's data save to HeroUnion failed, it will try again later.",
common.getTimeString(), task.notify_time, task.id);
console.error("[%s][%s] Task %s's data save to HeroUnion failed, it will try again later. Error message: %s",
common.getTimeString(), task.notify_time, task.id, saveRes.message);
}
this.updateTask(task.id, task); //更新任务数据

2
spider.mjs

@ -109,6 +109,8 @@ import cron from 'node-cron'; @@ -109,6 +109,8 @@ import cron from 'node-cron';
//上报联盟,任务失败
heroBot.saveTaskData(task.id, task.token, [], 'failed');
}else {
taskMoniter.setTaskWaiting(task.id); //重新进入等待处理状态
}
}

Loading…
Cancel
Save