startTask now takes args

This commit is contained in:
Girish Ramakrishnan
2018-11-29 23:28:26 -08:00
parent cbcadaa449
commit 30aea047e3
5 changed files with 7 additions and 6 deletions
+1 -1
View File
@@ -937,7 +937,7 @@ function ensureBackup(auditSource, callback) {
return callback(null);
}
tasks.startTask(tasks.TASK_BACKUP, auditSource, callback);
tasks.startTask(tasks.TASK_BACKUP, [], auditSource, callback);
});
});
}
+1 -1
View File
@@ -36,7 +36,7 @@ function list(req, res, next) {
function startBackup(req, res, next) {
// note that cloudron.backup only waits for backup initiation and not for backup to complete
// backup progress can be checked up ny polling the progress api call
tasks.startTask(tasks.TASK_BACKUP, auditSource(req), function (error) {
tasks.startTask(tasks.TASK_BACKUP, [], auditSource(req), function (error) {
if (error && error.reason === TasksError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));
+1 -1
View File
@@ -26,7 +26,7 @@ function backup(req, res, next) {
// note that cloudron.backup only waits for backup initiation and not for backup to complete
// backup progress can be checked up ny polling the progress api call
var auditSource = { userId: null, username: 'sysadmin' };
tasks.startTask(tasks.TASK_BACKUP, auditSource, function (error) {
tasks.startTask(tasks.TASK_BACKUP, [], auditSource, function (error) {
if (error && error.reason === TasksError.BAD_STATE) return next(new HttpError(409, error.message));
if (error) return next(new HttpError(500, error));
+3 -2
View File
@@ -100,8 +100,9 @@ function clearProgress(id, callback) {
setProgress(id, { percent: 0, message: 'Starting', result: '', errorMessage: '' }, callback);
}
function startTask(id, auditSource, callback) {
function startTask(id, args, auditSource, callback) {
assert.strictEqual(typeof id, 'string');
assert(Array.isArray(args));
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
@@ -126,7 +127,7 @@ function startTask(id, auditSource, callback) {
clearProgress(id, NOOP_CALLBACK);
eventlog.add(taskInfo.startEventId, auditSource, { });
gTasks[id] = child_process.fork(taskInfo.program, [ ], { stdio: [ 'pipe', fd, fd, 'ipc' ]});
gTasks[id] = child_process.fork(taskInfo.program, args, { stdio: [ 'pipe', fd, fd, 'ipc' ]});
gTasks[id].once('exit', function (code, signal) {
debug(`startTask: ${id} completed with code ${code} and signal ${signal}`);
+1 -1
View File
@@ -23,7 +23,7 @@ var async = require('async'),
tasks = require('../tasks.js');
function createBackup(callback) {
tasks.startTask(tasks.TASK_BACKUP, { username: 'test' }, function (error) { // this call does not wait for the backup!
tasks.startTask(tasks.TASK_BACKUP, [], { username: 'test' }, function (error) { // this call does not wait for the backup!
if (error) return callback(error);
function waitForBackup() {