port taskmanager to use tasks
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user