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

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ node_modules/
*.log *.log
.DS_Store .DS_Store
pixi.js/ pixi.js/
lab/audio/

View file

@ -27,6 +27,10 @@ function (http, nodeStatic) {
//console.log("data") //console.log("data")
}); });
req.addListener('error', function(err) {
console.log('');
});
req.addListener('end', function () { req.addListener('end', function () {
switch(true) { 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); this.server.listen(options.port);
console.checkpoint('start HTTP server'); console.checkpoint('start HTTP server');

View file

@ -1,7 +1,7 @@
{ {
"name": "chuck.js", "name": "chuck.js",
"author": "logsol <fartman@gmx.de>", "author": "logsol <fartman@gmx.de>",
"contributors": ["Jeena Paradies <spam@jeenaparadies.net> (http://jeena.net)"], "contributors": ["Jeena Paradies <spam@jeenaparadies.net> (https://jeena.net)"],
"description": "Multiplayer browser jump and run game", "description": "Multiplayer browser jump and run game",
"version": "0.1.0", "version": "0.1.0",
"homepage": "http://chuck-game.tumblr.com/", "homepage": "http://chuck-game.tumblr.com/",

View file

@ -21,7 +21,15 @@ var options = {
}; };
console.checkpoint = function (s) { console.checkpoint = function (s) {
console.log(' \033[34mbeep - \033[0m' + s); console.log(' \033[32mbeep - \033[0m' + s);
}
console.warn = function (s) {
console.log(' \033[33mwarn - \033[0m' + s);
}
console.error = function (s) {
console.log(' \033[31merror - \033[0m' + s);
} }
requirejs([ requirejs([