mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
show an error when port is already in use - fixes #42
This commit is contained in:
parent
413254bfa4
commit
5ba9a47948
4 changed files with 24 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@ node_modules/
|
|||
*.log
|
||||
.DS_Store
|
||||
pixi.js/
|
||||
lab/audio/
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "chuck.js",
|
||||
"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",
|
||||
"version": "0.1.0",
|
||||
"homepage": "http://chuck-game.tumblr.com/",
|
||||
|
|
|
|||
10
server.js
10
server.js
|
|
@ -21,7 +21,15 @@ var options = {
|
|||
};
|
||||
|
||||
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([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue