diff --git a/bin/unleash.js b/bin/unleash.js index ea6d9952ca..aa4ddef936 100755 --- a/bin/unleash.js +++ b/bin/unleash.js @@ -15,6 +15,12 @@ const argv = require('yargs') default: 4242, type: 'number', }) + .option('host', { + alias: 'l', + describe: 'The HTTP address the server will accept connections on.', + demand: false, + type: 'string', + }) .option('databaseUrl', { alias: 'd', describe: @@ -25,9 +31,9 @@ const argv = require('yargs') serverImpl .start(argv) - .then(conf => + .then(() => console.log( - `Unleash started on http://localhost:${conf.app.get('port')}` + `Unleash started on http://${argv.host || '127.0.0.1'}:${argv.port}` ) ) .catch(console.err); diff --git a/lib/options.js b/lib/options.js index 59411c41b9..7cb4250155 100644 --- a/lib/options.js +++ b/lib/options.js @@ -8,6 +8,7 @@ const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000; const DEFAULT_OPTIONS = { databaseUrl: process.env.DATABASE_URL, port: process.env.HTTP_PORT || process.env.PORT || 4242, + host: undefined, baseUriPath: process.env.BASE_URI_PATH || '', serverMetrics: true, enableLegacyRoutes: true, diff --git a/lib/server-impl.js b/lib/server-impl.js index 983d99661a..95e1f0a64c 100644 --- a/lib/server-impl.js +++ b/lib/server-impl.js @@ -26,7 +26,7 @@ function createApp(options) { ); const app = getApp(config); - const server = app.listen(app.get('port'), () => { + const server = app.listen(app.get('port'), options.host, () => { logger.info(`Unleash started on ${app.get('port')}`); });