diff --git a/package.json b/package.json index ae936509..2c9b0555 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Calvin Montgomery", "name": "CyTube", "description": "Online media synchronizer and chat", - "version": "3.74.0", + "version": "3.74.1", "repository": { "url": "http://github.com/calzoneman/sync" }, diff --git a/src/config.js b/src/config.js index 01e71d51..85f356a0 100644 --- a/src/config.js +++ b/src/config.js @@ -136,29 +136,19 @@ let captchaConfig = new CaptchaConfig(); * Initializes the configuration from the given YAML file */ exports.load = function (file) { + let absPath = path.join(__dirname, "..", file); try { - cfg = YAML.load(path.join(__dirname, "..", file)); + cfg = YAML.load(absPath); } catch (e) { if (e.code === "ENOENT") { - LOGGER.info(file + " does not exist, assuming default configuration"); - cfg = defaults; - return; + throw new Error(`No such file: ${absPath}`); } else { - LOGGER.error("Error loading config file " + file + ": "); - LOGGER.error(e); - if (e.stack) { - LOGGER.error(e.stack); - } - cfg = defaults; - return; + throw new Error(`Invalid config file ${absPath}: ${e}`); } } if (cfg == null) { - LOGGER.info(file + " is an Invalid configuration file, " + - "assuming default configuration"); - cfg = defaults; - return; + throw new Error("Configuration parser returned null"); } if (cfg.mail) { diff --git a/src/main.js b/src/main.js index e1634697..325d2e49 100644 --- a/src/main.js +++ b/src/main.js @@ -5,7 +5,15 @@ require('source-map-support').install(); const LOGGER = require('@calzoneman/jsli')('main'); -Config.load('config.yaml'); +try { + Config.load('config.yaml'); +} catch (e) { + LOGGER.fatal( + "Failed to load configuration: %s", + e + ); + process.exit(1); +} const sv = require('./server').init(); @@ -26,7 +34,14 @@ if (!Config.get('debug')) { function handleLine(line) { if (line === '/reload') { LOGGER.info('Reloading config'); - Config.load('config.yaml'); + try { + Config.load('config.yaml'); + } catch (e) { + LOGGER.error( + "Failed to load configuration: %s", + e + ); + } require('./web/pug').clearCache(); } else if (line.indexOf('/switch') === 0) { const args = line.split(' ');