Update config validation to allow for socket only

issue #887
This commit is contained in:
Hannah Wolfe 2013-10-10 16:11:35 +01:00
parent 97f592aa41
commit 31e2737cfd

View File

@ -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();
}