diff --git a/bin/unleash.js b/bin/unleash.js index aa4ddef936..b33badc736 100755 --- a/bin/unleash.js +++ b/bin/unleash.js @@ -31,9 +31,11 @@ const argv = require('yargs') serverImpl .start(argv) - .then(() => + .then(instance => { console.log( - `Unleash started on http://${argv.host || '127.0.0.1'}:${argv.port}` - ) - ) + `Unleash started on http://${instance.server.address().address}:${ + instance.server.address().port + }` + ); + }) .catch(console.err); diff --git a/lib/server-impl.js b/lib/server-impl.js index 95e1f0a64c..20e8f3f8ea 100644 --- a/lib/server-impl.js +++ b/lib/server-impl.js @@ -26,13 +26,14 @@ function createApp(options) { ); const app = getApp(config); - const server = app.listen(app.get('port'), options.host, () => { - logger.info(`Unleash started on ${app.get('port')}`); - }); - startMonitoring(options.serverMetrics, eventBus); - return { app, server, eventBus }; + return new Promise(resolve => { + const server = app.listen(app.get('port'), options.host, () => { + logger.info(`Unleash started on port ${server.address().port}`); + resolve({ app, server, eventBus }); + }); + }); } function start(opts) {