mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 01:15:47 +01:00
Fix alternate config file support (#6405)
This commit is contained in:
committed by
Julian Lam
parent
46576189be
commit
c93651b2d1
6
app.js
6
app.js
@@ -39,11 +39,7 @@ var file = require('./src/file');
|
|||||||
global.env = process.env.NODE_ENV || 'production';
|
global.env = process.env.NODE_ENV || 'production';
|
||||||
|
|
||||||
// Alternate configuration file support
|
// Alternate configuration file support
|
||||||
var configFile = path.join(__dirname, 'config.json');
|
var configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json');
|
||||||
|
|
||||||
if (nconf.get('config')) {
|
|
||||||
configFile = path.resolve(__dirname, nconf.get('config'));
|
|
||||||
}
|
|
||||||
|
|
||||||
var configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database'));
|
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 file = require('./src/file');
|
||||||
var pkg = require('./package.json');
|
var pkg = require('./package.json');
|
||||||
|
|
||||||
|
var pathToConfig = path.resolve(__dirname, process.env.CONFIG || 'config.json');
|
||||||
|
|
||||||
nconf.argv().env().file({
|
nconf.argv().env().file({
|
||||||
file: path.join(__dirname, 'config.json'),
|
file: pathToConfig,
|
||||||
});
|
});
|
||||||
|
|
||||||
var pidFilePath = path.join(__dirname, 'pidfile');
|
var pidFilePath = path.join(__dirname, 'pidfile');
|
||||||
@@ -152,7 +154,6 @@ function getPorts() {
|
|||||||
Loader.restart = function () {
|
Loader.restart = function () {
|
||||||
killWorkers();
|
killWorkers();
|
||||||
|
|
||||||
var pathToConfig = path.join(__dirname, '/config.json');
|
|
||||||
nconf.remove('file');
|
nconf.remove('file');
|
||||||
nconf.use('file', { file: pathToConfig });
|
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 (!err) {
|
||||||
if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) {
|
if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) {
|
||||||
if (file.existsSync(pidFilePath)) {
|
if (file.existsSync(pidFilePath)) {
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ if (!configExists && process.argv[2] !== 'setup') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.env.CONFIG = configFile;
|
||||||
|
|
||||||
// running commands
|
// running commands
|
||||||
program
|
program
|
||||||
.command('start')
|
.command('start')
|
||||||
|
|||||||
Reference in New Issue
Block a user