From 6b2e0f39730a836c3cf32ff56d851abe7ad9f4fa Mon Sep 17 00:00:00 2001 From: filesite Date: Fri, 19 Apr 2024 07:15:56 +0800 Subject: [PATCH] bug fix for status change --- lib/taskMoniter.mjs | 4 ++-- spider.mjs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/taskMoniter.mjs b/lib/taskMoniter.mjs index 330cd3a..6ad3db2 100644 --- a/lib/taskMoniter.mjs +++ b/lib/taskMoniter.mjs @@ -101,9 +101,9 @@ class TaskMoniter { return false; } + this.taskStatus[this.tasks[task_id].status] --; this.tasks[task_id].status = this.statusCode.waiting; this.tasks[task_id].updated = common.getTimestampInSeconds(); - this.taskStatus[this.tasks[task_id].status] --; this.taskStatus[this.statusCode.waiting] ++; return true; @@ -133,10 +133,10 @@ class TaskMoniter { return false; } + this.taskStatus[this.tasks[task_id].status] --; this.tasks[task_id].status = this.statusCode.failed; this.tasks[task_id].updated = common.getTimestampInSeconds(); this.taskStatus[this.statusCode.failed] ++; - this.taskStatus[this.statusCode.running] --; return true; } diff --git a/spider.mjs b/spider.mjs index 76b6c80..d80a30f 100644 --- a/spider.mjs +++ b/spider.mjs @@ -129,7 +129,6 @@ import path from 'node:path'; spider_is_running = false; }else { console.error('No bot matched with url %s', task.url); - taskMoniter.setTaskRunning(task.id); taskMoniter.setTaskFailed(task.id); } }, {