1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-28 00:17:12 +01:00

createApp should wait for server.listen callback

This commit is contained in:
Ivar Conradi Østhus 2018-05-06 12:17:46 +02:00
parent 4f808f13eb
commit 378544f326
2 changed files with 12 additions and 9 deletions

View File

@ -31,9 +31,11 @@ const argv = require('yargs')
serverImpl serverImpl
.start(argv) .start(argv)
.then(() => .then(instance => {
console.log( 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); .catch(console.err);

View File

@ -26,13 +26,14 @@ function createApp(options) {
); );
const app = getApp(config); 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); 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) { function start(opts) {