Add logFile option to startTask
This commit is contained in:
+5
-2
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user