diff --git a/src/node/hooks/express/adminsettings.js b/src/node/hooks/express/adminsettings.js index db4df750c..2a48d2899 100644 --- a/src/node/hooks/express/adminsettings.js +++ b/src/node/hooks/express/adminsettings.js @@ -1,5 +1,6 @@ var path = require('path'); var eejs = require('ep_etherpad-lite/node/eejs'); +var settings = require('ep_etherpad-lite/node/utils/Settings'); var installer = require('ep_etherpad-lite/static/js/pluginfw/installer'); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); var fs = require('fs'); @@ -44,6 +45,7 @@ exports.socketio = function (hook_name, args, cb) { socket.on("restartServer", function () { console.log("Admin request to restart server through a socket on /admin/settings"); + settings.reloadSettings(); hooks.aCallAll("restartServer", {}, function () {}); }); diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 4cc22045a..2ed76d0bd 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -112,51 +112,58 @@ exports.abiwordAvailable = function() } } -// Discover where the settings file lives -var settingsFilename = argv.settings || "settings.json"; -settingsFilename = path.resolve(path.join(root, settingsFilename)); -var settingsStr; -try{ - //read the settings sync - settingsStr = fs.readFileSync(settingsFilename).toString(); -} catch(e){ - console.warn('No settings file found. Continuing using defaults!'); -} -// try to parse the settings -var settings; -try { - if(settingsStr) { - settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json"); +exports.reloadSettings = function reloadSettings() { + // Discover where the settings file lives + var settingsFilename = argv.settings || "settings.json"; + settingsFilename = path.resolve(path.join(root, settingsFilename)); + + var settingsStr; + try{ + //read the settings sync + settingsStr = fs.readFileSync(settingsFilename).toString(); + } catch(e){ + console.warn('No settings file found. Continuing using defaults!'); } -}catch(e){ - console.error('There was an error processing your settings.json file: '+e.message); - process.exit(1); -} -//loop trough the settings -for(var i in settings) -{ - //test if the setting start with a low character - if(i.charAt(0).search("[a-z]") !== 0) + // try to parse the settings + var settings; + try { + if(settingsStr) { + settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json"); + } + }catch(e){ + console.error('There was an error processing your settings.json file: '+e.message); + process.exit(1); + } + + //loop trough the settings + for(var i in settings) { - console.warn("Settings should start with a low character: '" + i + "'"); + //test if the setting start with a low character + if(i.charAt(0).search("[a-z]") !== 0) + { + console.warn("Settings should start with a low character: '" + i + "'"); + } + + //we know this setting, so we overwrite it + //or it's a settings hash, specific to a plugin + if(exports[i] !== undefined || i.indexOf('ep_')==0) + { + exports[i] = settings[i]; + } + //this setting is unkown, output a warning and throw it away + else + { + console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); + } } - //we know this setting, so we overwrite it - //or it's a settings hash, specific to a plugin - if(exports[i] !== undefined || i.indexOf('ep_')==0) - { - exports[i] = settings[i]; - } - //this setting is unkown, output a warning and throw it away - else - { - console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); + if(exports.dbType === "dirty"){ + console.warn("DirtyDB is used. This is fine for testing but not recommended for production.") } } -if(exports.dbType === "dirty"){ - console.warn("DirtyDB is used. This is fine for testing but not recommended for production.") -} +// initially load settings +exports.reloadSettings();