From ac39e3b98e3afe3fb011c3b19e1ca522d691d94f Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 29 Oct 2013 10:58:06 +0100 Subject: [PATCH 1/4] Add EditorConfig. --- .editorconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..053b3f2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +# +# Tab indentation (size of 4 spaces) +[*] +end_of_line = lf +indent_size = 4 +indent_style = tab +insert_final_newline = true From e69db958b2110e38273d6ee0fc2aa12843a24b43 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 30 Oct 2013 12:21:10 +0100 Subject: [PATCH 2/4] Display an error message when the HTTP(S) server could not start. --- src/main.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main.js b/src/main.js index ef9824a..bfbfd05 100644 --- a/src/main.js +++ b/src/main.js @@ -161,11 +161,13 @@ xo.on('started', function () { // } // http_servers.forEach(function (http_server) { -// new WSServer({ -// 'server': http_server, -// 'path': '/websockify', -// }) -// .on('connection', on_connection); +// http_server.on('connection', function () { +// new WSServer({ +// 'server': http_server, +// 'path': '/websockify', +// }) +// .on('connection', on_connection); +// }); // }); // }); @@ -198,10 +200,12 @@ xo.on('started', function () { } http_servers.forEach(function (http_server) { - new WSServer({ - 'server': http_server, - 'path': '/api/', - }).on('connection', on_connection); + http_server.on('connection', function () { + new WSServer({ + 'server': http_server, + 'path': '/api/', + }).on('connection', on_connection); + }); }); }); @@ -380,7 +384,13 @@ read_file(__dirname +'/../config/local.yaml').then( require('http').createServer().listen(port, host) .on('listening', function () { console.info( - 'XO-Server HTTP server is listening on %s:%s', + 'HTTP server is listening on %s:%s', + host, port + ); + }) + .on('error', function () { + console.warn( + '[Warn] HTTP server could not listen on %s:%s', host, port ); }) @@ -402,7 +412,12 @@ read_file(__dirname +'/../config/local.yaml').then( 'key': key, }).listen(port, host).on('listening', function () { console.info( - 'XO-Server HTTPS server is listening on %s:%s', + 'HTTPS server is listening on %s:%s', + host, port + ); + }).on('error', function () { + console.warn( + '[Warn] HTTPS server could not listen on %s:%s', host, port ); }) From f23905f5ee055b96bf62383e26cb8c6236d5532f Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 30 Oct 2013 12:21:36 +0100 Subject: [PATCH 3/4] Use superstack to have better stacktraces with async code. --- package.json | 3 ++- src/main.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 03466bf..f48d362 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "underscore": ">=1.5.2", "validator": ">=1.2.1", "ws": ">=0.4.27", - "xmlrpc": ">=1.1.0" + "xmlrpc": ">=1.1.0", + "superstack": "0.0.3" }, "devDependencies": {}, "optionalDependencies": {}, diff --git a/src/main.js b/src/main.js index bfbfd05..f8f5b50 100644 --- a/src/main.js +++ b/src/main.js @@ -1,3 +1,12 @@ +// Enables strict mode for this whole file. +'use strict'; + +// node.js does not give complete stacktrace with async code, +// superstack is here for that! +require('superstack'); + +//------------------------------------- + var _ = require('underscore'); var connect = require('connect'); var fs = require('fs'); From 0f3c3920a1116f587910b93e7f0876bb0be8d818 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Wed, 30 Oct 2013 17:10:03 +0100 Subject: [PATCH 4/4] Bug fix. --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index f8f5b50..dbc16ff 100644 --- a/src/main.js +++ b/src/main.js @@ -170,7 +170,7 @@ xo.on('started', function () { // } // http_servers.forEach(function (http_server) { -// http_server.on('connection', function () { +// http_server.on('listening', function () { // new WSServer({ // 'server': http_server, // 'path': '/websockify', @@ -209,7 +209,7 @@ xo.on('started', function () { } http_servers.forEach(function (http_server) { - http_server.on('connection', function () { + http_server.on('listening', function () { new WSServer({ 'server': http_server, 'path': '/api/',