mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
Clean up using servers listening and error events
This commit is contained in:
parent
5caf5318dc
commit
c1956ac623
@ -28,14 +28,13 @@ function createApp(options) {
|
|||||||
const app = getApp(config);
|
const app = getApp(config);
|
||||||
startMonitoring(options.serverMetrics, eventBus);
|
startMonitoring(options.serverMetrics, eventBus);
|
||||||
|
|
||||||
return new Promise(resolve => {
|
const server = app.listen({ port: options.port, host: options.host }, () =>
|
||||||
const server = app.listen(
|
logger.info(`Unleash started on port ${server.address().port}`)
|
||||||
{ port: options.port, host: options.host },
|
);
|
||||||
() => {
|
|
||||||
logger.info(`Unleash started on port ${server.address().port}`);
|
return new Promise((resolve, reject) => {
|
||||||
resolve({ app, server, eventBus });
|
server.on('listening', () => resolve({ app, server, eventBus }));
|
||||||
}
|
server.on('error', reject);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +43,7 @@ function start(opts) {
|
|||||||
|
|
||||||
return migrator({ databaseUrl: options.databaseUrl })
|
return migrator({ databaseUrl: options.databaseUrl })
|
||||||
.catch(err => logger.error('failed to migrate db', err))
|
.catch(err => logger.error('failed to migrate db', err))
|
||||||
.then(() => createApp(options))
|
.then(() => createApp(options));
|
||||||
.catch(err => logger.error('failed creating app', err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
Reference in New Issue
Block a user