Add logFile option to startTask

This commit is contained in:
Girish Ramakrishnan
2019-08-27 11:38:12 -07:00
parent e560c18b57
commit f535b3de2f
2 changed files with 7 additions and 3 deletions
+5 -2
View File
@@ -98,16 +98,19 @@ function update(id, task, callback) {
});
}
function startTask(type, args) {
function startTask(type, args, options) {
assert.strictEqual(typeof type, 'string');
assert(Array.isArray(args));
assert(!options || typeof options === 'object');
let events = new EventEmitter();
options = options || {};
taskdb.add({ type: type, percent: 0, message: 'Starting', args: args }, function (error, taskId) {
if (error) return events.emit('error', new TaskError(TaskError.INTERNAL_ERROR, error));
const logFile = `${paths.TASKS_LOG_DIR}/${taskId}.log`;
const logFile = options.logFile || `${paths.TASKS_LOG_DIR}/${taskId}.log`;
let fd = safe.fs.openSync(logFile, 'w'); // will autoclose
if (!fd) {
debug(`startTask: unable to get log filedescriptor ${safe.error.message}`);