From 0d6772c30b4aa5f35b107838f23b90aa8291d7e3 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 17 Apr 2015 17:52:11 -0400 Subject: [PATCH] warning/errors on invalid ports config --- src/webserver.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/webserver.js b/src/webserver.js index 8671209113..da998cae06 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -33,6 +33,21 @@ if(nconf.get('ssl')) { (function (app) { var port = nconf.get('port'); + if (Array.isArray(port)) { + if (!port.length) { + winston.error('[startup] empty ports array in config.json'); + process.exit(); + } + + winston.warn('[startup] If you want to start nodebb on multiple ports please use loader.js'); + winston.warn('[startup] Defaulting to first port in array, ' + port[0]); + port = port[0]; + if (!port) { + winston.error('[startup] Invalid port, exiting'); + process.exit(); + } + } + module.exports.init = function() { var skipJS, skipLess, fromFile = nconf.get('from-file') || ''; @@ -164,6 +179,10 @@ if(nconf.get('ssl')) { }; module.exports.testSocket = function(socketPath, callback) { + if (typeof socketPath !== 'string') { + return callback(new Error('invalid socket path : ' + socketPath)); + } + async.series([ function(next) { fs.exists(socketPath, function(exists) {