implement manifest.logPaths
This commit is contained in:
18
src/apps.js
18
src/apps.js
@@ -1797,11 +1797,27 @@ async function getLogPaths(app) {
|
||||
|
||||
const appId = app.id;
|
||||
|
||||
var filePaths = [];
|
||||
const 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`));
|
||||
|
||||
if (app.manifest.logPaths) {
|
||||
const [error, result] = await safe(docker.inspect(app.containerId));
|
||||
if (!error) {
|
||||
const runVolume = result.Mounts.find(function (mount) { return mount.Destination === '/run'; });
|
||||
const tmpVolume = result.Mounts.find(function (mount) { return mount.Destination === '/tmp'; });
|
||||
const dataVolume = result.Mounts.find(function (mount) { return mount.Destination === '/app/data'; });
|
||||
|
||||
// note: wild cards are not supported yet in logPaths since that will require shell expansion
|
||||
for (const logPath of app.manifest.logPaths) {
|
||||
if (logPath.startsWith('/tmp/')) filePaths.push(`${tmpVolume.Source}/${logPath.slice('/tmp/'.length)}`);
|
||||
else if (logPath.startsWith('/run/')) filePaths.push(`${runVolume.Source}/${logPath.slice('/run/'.length)}`);
|
||||
else if (logPath.startsWith('/app/data/')) filePaths.push(`${dataVolume.Source}/${logPath.slice('/app/data/'.length)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user