From d558508cd6e63a0897a90a776cf8de06fda8cc6c Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Mon, 22 Apr 2013 00:39:46 +0100 Subject: [PATCH] Show an error when we're unable to bind to an address/port Fixes #213 --- server/kiwi.js | 11 ++++++++++- server/weblistener.js | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/kiwi.js b/server/kiwi.js index 0dc1d49..6e697f7 100755 --- a/server/kiwi.js +++ b/server/kiwi.js @@ -172,7 +172,16 @@ _.each(global.config.servers, function (server) { clients.remove(client); }); - wl.on('listening', webListenerRunning); + wl.on('listening', function () { + console.log('Listening on %s:%s %s SSL', server.address, server.port, (server.ssl ? 'with' : 'without')); + webListenerRunning(); + }); + + wl.on('error', function (err) { + console.log('Error listening on %s:%s: %s', server.address, server.port, err.code); + // TODO: This should probably be refactored. ^JA + webListenerRunning(); + }); }); // Once all the listeners are listening, set the processes UID/GID diff --git a/server/weblistener.js b/server/weblistener.js index 27c8eab..80fb2af 100644 --- a/server/weblistener.js +++ b/server/weblistener.js @@ -64,8 +64,6 @@ var WebListener = function (web_config, transports) { hs.listen(web_config.port, web_config.address, function () { that.emit('listening'); }); - - console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' with SSL'); } else { // Start some plain-text server up @@ -76,9 +74,11 @@ var WebListener = function (web_config, transports) { hs.listen(web_config.port, web_config.address, function () { that.emit('listening'); }); - - console.log('Listening on ' + web_config.address + ':' + web_config.port.toString() + ' without SSL'); } + + hs.on('error', function (err) { + that.emit('error', err); + }) this.ws.enable('browser client minification'); this.ws.enable('browser client etag'); -- 2.25.1