For app tickets, send the log files along
This commit is contained in:
19
src/apps.js
19
src/apps.js
@@ -41,6 +41,7 @@ exports = module.exports = {
|
||||
backup: backup,
|
||||
listBackups: listBackups,
|
||||
|
||||
getLocalLogfilePaths: getLocalLogfilePaths,
|
||||
getLogs: getLogs,
|
||||
|
||||
start: start,
|
||||
@@ -1365,6 +1366,19 @@ function update(app, data, auditSource, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function getLocalLogfilePaths(app) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
|
||||
const appId = app.id;
|
||||
|
||||
var filePaths = [];
|
||||
filePaths.push(path.join(paths.LOG_DIR, appId, 'apptask.log'));
|
||||
filePaths.push(path.join(paths.LOG_DIR, appId, 'app.log'));
|
||||
if (app.manifest.addons && app.manifest.addons.redis) filePaths.push(path.join(paths.LOG_DIR, `redis-${appId}/app.log`));
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
function getLogs(app, options, callback) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert(options && typeof options === 'object');
|
||||
@@ -1384,11 +1398,8 @@ function getLogs(app, options, callback) {
|
||||
|
||||
var 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
|
||||
args.push(path.join(paths.LOG_DIR, appId, 'apptask.log'));
|
||||
args.push(path.join(paths.LOG_DIR, appId, 'app.log'));
|
||||
if (app.manifest.addons && app.manifest.addons.redis) args.push(path.join(paths.LOG_DIR, `redis-${appId}/app.log`));
|
||||
|
||||
var cp = spawn('/usr/bin/tail', args);
|
||||
var cp = spawn('/usr/bin/tail', args.concat(getLocalLogfilePaths(app)));
|
||||
|
||||
var transformStream = split(function mapper(line) {
|
||||
if (format !== 'json') return line + '\n';
|
||||
|
||||
Reference in New Issue
Block a user