From 31e2737cfd449ce26c13bf14aec83bfc55cb493c Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Thu, 10 Oct 2013 16:11:35 +0100 Subject: [PATCH] Update config validation to allow for socket only issue #887 --- core/config-loader.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/config-loader.js b/core/config-loader.js index b22c77a1e7..2cc66f1f07 100644 --- a/core/config-loader.js +++ b/core/config-loader.js @@ -36,6 +36,8 @@ function writeConfigFile() { function validateConfigEnvironment() { var envVal = process.env.NODE_ENV || 'undefined', + hasHostAndPort, + hasSocket, config, parsedUrl; @@ -45,6 +47,7 @@ function validateConfigEnvironment() { } + // Check if we don't even have a config if (!config) { errors.logError(new Error('Cannot find the configuration for the current NODE_ENV'), "NODE_ENV=" + envVal, 'Ensure your config.js has a section for the current NODE_ENV value'); @@ -64,9 +67,12 @@ function validateConfigEnvironment() { return when.reject(); } + hasHostAndPort = config.server && !!config.server.host && !!config.server.port; + hasSocket = config.server && !!config.server.socket; + // Check for valid server host and port values - if (!config.server || !config.server.host || !config.server.port) { - errors.logError(new Error('Your server values (host and port) in config.js are invalid.'), JSON.stringify(config.server), 'Please provide them before restarting.'); + if (!config.server || !(hasHostAndPort || hasSocket)) { + errors.logError(new Error('Your server values (socket, or host and port) in config.js are invalid.'), JSON.stringify(config.server), 'Please provide them before restarting.'); return when.reject(); }