diff --git a/lib/arguments.js b/lib/arguments.js index ba2e31e..95e9d52 100644 --- a/lib/arguments.js +++ b/lib/arguments.js @@ -36,5 +36,9 @@ module.exports = { debug: { alias: 'd', describe: 'Force run the server in development mode' - } + }, + ip: { + alias: 'i', + describe: 'IP server runs on [default: 0.0.0.0]' + }, }; diff --git a/lib/config.js b/lib/config.js index 421f19c..587b108 100644 --- a/lib/config.js +++ b/lib/config.js @@ -27,6 +27,7 @@ nconf.file(nconf.get('config') || './config.json'); nconf.defaults({ name: nconf.get('name') || 'spserver', NODE_ENV: 'development', + ip: '0.0.0.0', production: { port: 80, bunyan: { diff --git a/lib/spserver.js b/lib/spserver.js index b80d982..d4523fb 100644 --- a/lib/spserver.js +++ b/lib/spserver.js @@ -26,9 +26,9 @@ function _resolveFinalSettings(settings) { 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 - _(['name', 'file', 'serve', 'port']).forEach(function (field) { + _(['name', 'file', 'serve', 'ip', 'port']).forEach(function (field) { finalSettings[field] = settings[field] || settings[env][field]; }); @@ -105,7 +105,7 @@ var spserver = function (settings) { }).resume(); }); - server.listen(finalSettings.port); + server.listen(finalSettings.port, finalSettings.ip); logger.info( 'Started single-page server: ' + finalSettings.name +