diff --git a/src/apptask.js b/src/apptask.js index a245fb5a7..1b864e732 100644 --- a/src/apptask.js +++ b/src/apptask.js @@ -329,10 +329,8 @@ function cleanupLogs(app, callback) { assert.strictEqual(typeof app, 'object'); assert.strictEqual(typeof callback, 'function'); - const logFolder = path.join(paths.LOG_FOLDER, app.id); - - rimraf(logFolder, function (error) { - if (error) debugApp(app, 'cannot cleanup logs at %s: %s', logFolder, error); + rimraf(path.join(paths.LOG_DIR, app.id), function (error) { + if (error) debugApp(app, 'cannot cleanup logs: %s', error); callback(null); }); } diff --git a/src/config.js b/src/config.js index b9d1670f4..7fcf092e0 100644 --- a/src/config.js +++ b/src/config.js @@ -2,6 +2,7 @@ exports = module.exports = { baseDir: baseDir, + logDir: logDir, // values set here will be lost after a upgrade/update. use the sqlite database // for persistent values that need to be backed up @@ -61,6 +62,11 @@ function baseDir() { if (exports.TEST) return path.join(homeDir, '.cloudron_test'); } +function logDir() { + if (exports.CLOUDRON) return '/var/log'; + if (exports.TEST) return path.join(homeDir, '.cloudron_test', 'log'); +} + var cloudronConfigFileName = path.join(baseDir(), 'configs/cloudron.conf'); // only tests can run without a config file on disk, they use the defaults with runtime overrides diff --git a/src/paths.js b/src/paths.js index 13be4ee84..f8ca66437 100644 --- a/src/paths.js +++ b/src/paths.js @@ -35,5 +35,5 @@ exports = module.exports = { AUTO_PROVISION_FILE: path.join(config.baseDir(), 'configs/autoprovision.json'), - LOG_FOLDER: '/var/log/cloudron' + LOG_DIR: path.join(config.logDir(), 'cloudron') }; diff --git a/src/taskmanager.js b/src/taskmanager.js index a40506508..b0de865a3 100644 --- a/src/taskmanager.js +++ b/src/taskmanager.js @@ -127,8 +127,8 @@ function startAppTask(appId, callback) { } // ensure log folder - mkdirp.sync(path.join(paths.LOG_FOLDER, appId)); - var logFilePath = path.join(paths.LOG_FOLDER, appId, 'apptask-' + Date.now() + '.log'); + mkdirp.sync(path.join(paths.LOG_DIR, appId)); + var logFilePath = path.join(paths.LOG_DIR, appId, 'apptask-' + Date.now() + '.log'); // will autoclose fs.open(logFilePath, 'w', function (error, fd) {