diff --git a/src/backuptask.js b/src/backuptask.js index def532164..081ffe93c 100644 --- a/src/backuptask.js +++ b/src/backuptask.js @@ -159,7 +159,7 @@ async function runBackupUpload(uploadConfig, progressCallback) { result = progress.result; } - const [error] = await safe(shell.promises.sudo(`backup-${remotePath}`, [ BACKUP_UPLOAD_CMD, remotePath, backupConfig.format, dataLayout.toString() ], { env: envCopy, preserveEnv: true, ipc: true, onMessage })); + const [error] = await safe(shell.promises.sudo(`backup-${remotePath}`, [ BACKUP_UPLOAD_CMD, remotePath, backupConfig.format, dataLayout.toString() ], { env: envCopy, preserveEnv: true, ipc: true, onMessage, outputHasTimestamps: true })); if (error && (error.code === null /* signal */ || (error.code !== 0 && error.code !== 50))) { // backuptask crashed throw new BoxError(BoxError.INTERNAL_ERROR, 'Backuptask crashed'); } else if (error && error.code === 50) { // exited with error diff --git a/src/shell.js b/src/shell.js index c05a1b5d8..82a5c9b12 100644 --- a/src/shell.js +++ b/src/shell.js @@ -98,6 +98,8 @@ function sudo(tag, args, options, callback) { callback = once(callback); // exit may or may not be called after an 'error' + const logFunc = options.outputHasTimestamps ? process.stdoud.write : debug; + if (options.ipc) { sudoArgs.push('--close-from=4'); // keep the ipc open. requires closefrom_override in sudoers file options.stdio = ['pipe', 'pipe', 'pipe', 'ipc']; @@ -111,11 +113,9 @@ function sudo(tag, args, options, callback) { cp.stdout.on('data', (data) => { if (options.captureStdout) stdoutResult += data.toString('utf8'); - if (!options.quiet) process.stdout.write(data); // do not use debug to avoid double timestamps when calling backupupload.js - }); - cp.stderr.on('data', (data) => { - process.stderr.write(data); // do not use debug to avoid double timestamps when calling backupupload.js + if (!options.quiet) logFunc(data.toString('utf8')); }); + cp.stderr.on('data', (data) => logFunc(data.toString('utf8'))); cp.on('exit', function (code, signal) { if (code === 0) return callback(null, options.captureStdout ? stdoutResult : null);