Browse Source

bug fix: task and notify status changed small than zero

master
filesite 7 months ago
parent
commit
25b2298ae8
  1. 21
      heroUnion.mjs

21
heroUnion.mjs

@ -469,12 +469,21 @@ class HeroUnion {
(item.status == 'done' || item.status == 'failed') (item.status == 'done' || item.status == 'failed')
&& timestamp - item.created > _self.task_cache_time && timestamp - item.created > _self.task_cache_time
) { ) {
_self.taskStatus[item.status] --; if (_self.taskStatus[item.status] >= 1) {
_self.taskStatus.total --; _self.taskStatus[item.status] --;
}
if (_self.taskStatus.total >= 1) {
_self.taskStatus.total --;
}
let notify_status = item.notified ? 'done' : 'failed'; let notify_status = item.notified ? 'done' : 'failed';
_self.taskNotifyStatus[notify_status] --; if (_self.taskNotifyStatus[notify_status] >= 1) {
_self.taskNotifyStatus.total --; _self.taskNotifyStatus[notify_status] --;
}
if (_self.taskNotifyStatus.total >= 1) {
_self.taskNotifyStatus.total --;
}
common.log('Task %s is expired, which is created at %s', item.id, item.created); common.log('Task %s is expired, which is created at %s', item.id, item.created);
}else { }else {
accumulator.push(item); accumulator.push(item);
@ -512,14 +521,14 @@ class HeroUnion {
_self.taskStatus.running --; _self.taskStatus.running --;
_self.taskStatus.waiting ++; _self.taskStatus.waiting ++;
_self.tasks[index].status = 'waiting'; _self.tasks[index].status = 'waiting';
common.log('Task %s running timeout, and reset it to waiting list', item.id); common.log('Task %s running timeout, and reset it to waiting list, url: %s', item.id, item.url);
}else if (item.status == 'running' && item.try_time >= _self.task_max_try) { }else if (item.status == 'running' && item.try_time >= _self.task_max_try) {
//设置任务失败 //设置任务失败
_self.taskStatus.running --; _self.taskStatus.running --;
_self.taskStatus.failed ++; _self.taskStatus.failed ++;
_self.tasks[index].status = 'failed'; _self.tasks[index].status = 'failed';
_self.tasks[index].error = 'Task max try time got.'; _self.tasks[index].error = 'Task max try time got.';
common.error('Task %s failed, got the max try time.', item.id); common.error('Task %s failed, got the max try time, url: %s.', item.id, item.url);
} }
}); });
}, { }, {

Loading…
Cancel
Save