Add IP config option

This commit is contained in:
Misha Wolfson 2016-12-16 20:18:39 -05:00
parent 5a67343957
commit 0365ce1095
3 changed files with 9 additions and 4 deletions

View file

@ -36,5 +36,9 @@ module.exports = {
debug: { debug: {
alias: 'd', alias: 'd',
describe: 'Force run the server in development mode' describe: 'Force run the server in development mode'
} },
ip: {
alias: 'i',
describe: 'IP server runs on [default: 0.0.0.0]'
},
}; };

View file

@ -27,6 +27,7 @@ nconf.file(nconf.get('config') || './config.json');
nconf.defaults({ nconf.defaults({
name: nconf.get('name') || 'spserver', name: nconf.get('name') || 'spserver',
NODE_ENV: 'development', NODE_ENV: 'development',
ip: '0.0.0.0',
production: { production: {
port: 80, port: 80,
bunyan: { bunyan: {

View file

@ -26,9 +26,9 @@ function _resolveFinalSettings(settings) {
settings[env] = {}; settings[env] = {};
} }
// For 'name', 'file', 'serve', and 'port', default to the global setting rather than an // For 'name', 'file', 'serve', 'ip', and 'port', default to the global setting rather than an
// individual environment's setting, because it might have been set via command-line flags // individual environment's setting, because it might have been set via command-line flags
_(['name', 'file', 'serve', 'port']).forEach(function (field) { _(['name', 'file', 'serve', 'ip', 'port']).forEach(function (field) {
finalSettings[field] = settings[field] || settings[env][field]; finalSettings[field] = settings[field] || settings[env][field];
}); });
@ -105,7 +105,7 @@ var spserver = function (settings) {
}).resume(); }).resume();
}); });
server.listen(finalSettings.port); server.listen(finalSettings.port, finalSettings.ip);
logger.info( logger.info(
'Started single-page server: ' + finalSettings.name + 'Started single-page server: ' + finalSettings.name +