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);
|
||||
startMonitoring(options.serverMetrics, eventBus);
|
||||
|
||||
return new Promise(resolve => {
|
||||
const server = app.listen(
|
||||
{ port: options.port, host: options.host },
|
||||
() => {
|
||||
logger.info(`Unleash started on port ${server.address().port}`);
|
||||
resolve({ app, server, eventBus });
|
||||
}
|
||||
const server = app.listen({ port: options.port, host: options.host }, () =>
|
||||
logger.info(`Unleash started on port ${server.address().port}`)
|
||||
);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
server.on('listening', () => resolve({ app, server, eventBus }));
|
||||
server.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
@ -44,8 +43,7 @@ function start(opts) {
|
||||
|
||||
return migrator({ databaseUrl: options.databaseUrl })
|
||||
.catch(err => logger.error('failed to migrate db', err))
|
||||
.then(() => createApp(options))
|
||||
.catch(err => logger.error('failed creating app', err));
|
||||
.then(() => createApp(options));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
Loading…
Reference in New Issue
Block a user