catch bind errors

This commit is contained in:
Alex Kocharin 2013-12-19 07:17:52 +04:00
parent 225c2bb65f
commit 503b60a45b
1 changed files with 7 additions and 1 deletions

View File

@ -98,7 +98,13 @@ function afterConfigLoad() {
logger.setup(config.logs)
var hostport = get_hostport()
server(config).listen(hostport[1], hostport[0])
server(config)
.listen(hostport[1], hostport[0])
.on('error', function(err) {
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}')
process.exit(2)
})
logger.logger.warn({addr: 'http://'+hostport[0]+':'+hostport[1]+'/', version: 'Sinopia/'+pkg.version}, 'Server is listening on @{addr}')
// undocumented stuff for tests