port taskmanager to use tasks

This commit is contained in:
Girish Ramakrishnan
2019-08-28 15:00:55 -07:00
parent be6b172d6f
commit 9f1210202a
6 changed files with 132 additions and 220 deletions
+10
View File
@@ -10,6 +10,7 @@ exports = module.exports = {
startTask: startTask,
stopTask: stopTask,
stopAllTasks: stopAllTasks,
removePrivateFields: removePrivateFields,
@@ -31,6 +32,7 @@ exports = module.exports = {
};
let assert = require('assert'),
async = require('async'),
child_process = require('child_process'),
DatabaseError = require('./databaseerror.js'),
debug = require('debug')('box:tasks'),
@@ -169,6 +171,14 @@ function stopTask(id, callback) {
callback(null);
}
function stopAllTasks(callback) {
assert.strictEqual(typeof callback, 'function');
async.eachSeries(Object.keys(gTasks), function (id, iteratorDone) {
stopTask(id, () => iteratorDone()); // ignore any error
}, callback);
}
function listByTypePaged(type, page, perPage, callback) {
assert(typeof type === 'string' || type === null);
assert.strictEqual(typeof page, 'number');