diff --git a/core/archive_util.js b/core/archive_util.js index c0076dba..32425eaa 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -6,6 +6,7 @@ const Config = require('./config.js').get; const stringFormat = require('./string_format.js'); const Errors = require('./enig_error.js').Errors; const resolveMimeType = require('./mime_util.js').resolveMimeType; +const Events = require('./events.js'); // base/modules const fs = require('graceful-fs'); @@ -58,9 +59,13 @@ module.exports = class ArchiveUtil { } init() { - // - // Load configuration - // + this.reloadConfig(); + Events.on(Events.getSystemEvents().ConfigChanged, () => { + this.reloadConfig(); + }); + } + + reloadConfig() { const config = Config(); if(_.has(config, 'archives.archivers')) { Object.keys(config.archives.archivers).forEach(archKey => { diff --git a/core/config.js b/core/config.js index f85ffe2a..1e69b6ef 100644 --- a/core/config.js +++ b/core/config.js @@ -94,7 +94,12 @@ function init(configPath, options, cb) { const reCachedPath = paths.join(fileRoot, fileName); ConfigCache.getConfig(reCachedPath, (err, config) => { if(!err) { - mergeValidateAndFinalize(config); + mergeValidateAndFinalize(config, err => { + if(!err) { + const Events = require('./events.js'); + Events.emit(Events.getSystemEvents().ConfigChanged); + } + }); } }); }; diff --git a/core/system_events.js b/core/system_events.js index 95316c95..42aa0700 100644 --- a/core/system_events.js +++ b/core/system_events.js @@ -6,10 +6,10 @@ module.exports = { ClientDisconnected : 'codes.l33t.enigma.system.disconnected', // { client, connectionCount } TermDetected : 'codes.l33t.enigma.system.term_detected', // { client } - ThemeChanged : 'codes.l33t.enigma.system.theme_changed', // { themeId } - ConfigChanged : 'codes.l33t.enigma.system.config_changed', - MenusChanged : 'codes.l33t.enigma.system.menus_changed', - PromptsChanged : 'codes.l33t.enigma.system.prompts_changed', + ThemeChanged : 'codes.l33t.enigma.system.theme_changed', // (theme.hjson): { themeId } + ConfigChanged : 'codes.l33t.enigma.system.config_changed', // (config.hjson) + MenusChanged : 'codes.l33t.enigma.system.menus_changed', // (menu.hjson) + PromptsChanged : 'codes.l33t.enigma.system.prompts_changed', // (prompt.hjson) // User - includes { user, ...} NewUser : 'codes.l33t.enigma.system.new_user',