show an error when port is already in use - fixes #42

This commit is contained in:
logsol 2014-02-24 10:39:25 +01:00
parent 413254bfa4
commit 5ba9a47948
4 changed files with 24 additions and 2 deletions

View file

@ -27,6 +27,10 @@ function (http, nodeStatic) {
//console.log("data")
});
req.addListener('error', function(err) {
console.log('');
});
req.addListener('end', function () {
switch(true) {
@ -67,6 +71,15 @@ function (http, nodeStatic) {
});
}
);
this.server.once('error', function(err) {
if(err.code == 'EADDRINUSE') {
console.error('port already in use. Closing.');
} else {
throw new Error(err);
}
});
this.server.listen(options.port);
console.checkpoint('start HTTP server');