mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	createApp should wait for server.listen callback
This commit is contained in:
		
							parent
							
								
									07ad3faaff
								
							
						
					
					
						commit
						54073a8293
					
				@ -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);
 | 
				
			||||||
 | 
				
			|||||||
@ -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) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user