Fix alternate config file support (#6405)

v1.18.x
Peter Jaszkowiak 7 years ago committed by Julian Lam
parent 46576189be
commit c93651b2d1

@ -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'));

@ -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)) {

@ -105,6 +105,8 @@ if (!configExists && process.argv[2] !== 'setup') {
return;
}
process.env.CONFIG = configFile;
// running commands
program
.command('start')

Loading…
Cancel
Save