diff --git a/src/apps.js b/src/apps.js index 2b378173b..33b8c3bc5 100644 --- a/src/apps.js +++ b/src/apps.js @@ -56,7 +56,7 @@ exports = module.exports = { listBackups, getTask, - getLocalLogfilePaths, + getLogPaths, getLogs, getCertificate, @@ -1792,7 +1792,7 @@ async function updateApp(app, data, auditSource) { return { taskId }; } -function getLocalLogfilePaths(app) { +async function getLogPaths(app) { assert.strictEqual(typeof app, 'object'); const appId = app.id; @@ -1824,7 +1824,8 @@ async function getLogs(app, options) { const args = [ '--lines=' + lines ]; if (follow) args.push('--follow', '--retry', '--quiet'); // same as -F. to make it work if file doesn't exist, --quiet to not output file headers, which are no logs - const cp = spawn('/usr/bin/tail', args.concat(getLocalLogfilePaths(app))); + const logPaths = await getLogPaths(app); + const cp = spawn('/usr/bin/tail', args.concat(logPaths)); const transformStream = split(function mapper(line) { if (format !== 'json') return line + '\n'; diff --git a/src/appstore.js b/src/appstore.js index 9b2da6cf2..30137da7c 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -393,10 +393,11 @@ async function createTicket(info, auditSource) { if (info.app) { request.field('infoJSON', JSON.stringify(info)); - apps.getLocalLogfilePaths(info.app).forEach(function (filePath) { - const logs = safe.child_process.execSync(`tail --lines=1000 ${filePath}`); - if (logs) request.attach(path.basename(filePath), logs, path.basename(filePath)); - }); + const logPaths = await apps.getLogPaths(info.app); + for (const logPath of logPaths) { + const logs = safe.child_process.execSync(`tail --lines=1000 ${logPath}`); + if (logs) request.attach(path.basename(logPath), logs, path.basename(logPath)); + } } else { request.send(info); }