Browse Source

task moniter ready

master
filesite 1 year ago
parent
commit
e80479b1e1
  1. 41
      lib/taskMoniter.mjs

41
lib/taskMoniter.mjs

@ -39,16 +39,50 @@ class TaskMoniter { @@ -39,16 +39,50 @@ class TaskMoniter {
return this.taskStatus;
}
async getNewTask() {
getNewTask() {
let task = null;
for (const item of this.tasks) {
if (item.status == this.statusCode.waiting) {
task = item;
break;
}
}
return task;
}
async setTaskDone(task) {
setTaskRunning(task_id) {
if (typeof(this.tasks[task_id]) == 'undefined') {
return false;
}
this.tasks[task_id].status = this.statusCode.running;
this.taskStatus[this.statusCode.running] ++;
return true;
}
async setTaskFailed(task) {
setTaskDone(task_id) {
if (typeof(this.tasks[task_id]) == 'undefined') {
return false;
}
this.tasks[task_id].status = this.statusCode.done;
this.taskStatus[this.statusCode.done] ++;
return true;
}
setTaskFailed(task_id) {
if (typeof(this.tasks[task_id]) == 'undefined') {
return false;
}
this.tasks[task_id].status = this.statusCode.failed;
this.taskStatus[this.statusCode.failed] ++;
return true;
}
async parseTaskFile(filename, filepath) {
@ -77,7 +111,6 @@ class TaskMoniter { @@ -77,7 +111,6 @@ class TaskMoniter {
this.tasks[task.id] = task;
this.taskStatus[task.status] ++;
this.taskStatus.total ++;
//console.log('Task added', task);
return true;
}

Loading…
Cancel
Save