diff --git a/app.js b/app.js index 748a68bb54..4c910262bc 100644 --- a/app.js +++ b/app.js @@ -39,11 +39,7 @@ var file = require('./src/file'); global.env = process.env.NODE_ENV || 'production'; // Alternate configuration file support -var configFile = path.join(__dirname, 'config.json'); - -if (nconf.get('config')) { - configFile = path.resolve(__dirname, nconf.get('config')); -} +var configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'); var configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database')); diff --git a/loader.js b/loader.js index 434e2cce5c..f5793e8aff 100644 --- a/loader.js +++ b/loader.js @@ -11,8 +11,10 @@ var logrotate = require('logrotate-stream'); var file = require('./src/file'); var pkg = require('./package.json'); +var pathToConfig = path.resolve(__dirname, process.env.CONFIG || 'config.json'); + nconf.argv().env().file({ - file: path.join(__dirname, 'config.json'), + file: pathToConfig, }); var pidFilePath = path.join(__dirname, 'pidfile'); @@ -152,7 +154,6 @@ function getPorts() { Loader.restart = function () { killWorkers(); - var pathToConfig = path.join(__dirname, '/config.json'); nconf.remove('file'); nconf.use('file', { file: pathToConfig }); @@ -212,7 +213,7 @@ Loader.notifyWorkers = function (msg, worker_pid) { }); }; -fs.open(path.join(__dirname, 'config.json'), 'r', function (err) { +fs.open(pathToConfig, 'r', function (err) { if (!err) { if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) { if (file.existsSync(pidFilePath)) { diff --git a/src/cli/index.js b/src/cli/index.js index e4679a4e19..cece70d554 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -105,6 +105,8 @@ if (!configExists && process.argv[2] !== 'setup') { return; } +process.env.CONFIG = configFile; + // running commands program .command('start')