mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Add ability to reload settings
This commit is contained in:
parent
7febd3ff5c
commit
e702a86c9f
1 changed files with 45 additions and 38 deletions
|
@ -112,32 +112,35 @@ 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{
|
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
|
//read the settings sync
|
||||||
settingsStr = fs.readFileSync(settingsFilename).toString();
|
settingsStr = fs.readFileSync(settingsFilename).toString();
|
||||||
} catch(e){
|
} catch(e){
|
||||||
console.warn('No settings file found. Continuing using defaults!');
|
console.warn('No settings file found. Continuing using defaults!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to parse the settings
|
// try to parse the settings
|
||||||
var settings;
|
var settings;
|
||||||
try {
|
try {
|
||||||
if(settingsStr) {
|
if(settingsStr) {
|
||||||
settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json");
|
settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json");
|
||||||
}
|
}
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.error('There was an error processing your settings.json file: '+e.message);
|
console.error('There was an error processing your settings.json file: '+e.message);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//loop trough the settings
|
//loop trough the settings
|
||||||
for(var i in settings)
|
for(var i in settings)
|
||||||
{
|
{
|
||||||
//test if the setting start with a low character
|
//test if the setting start with a low character
|
||||||
if(i.charAt(0).search("[a-z]") !== 0)
|
if(i.charAt(0).search("[a-z]") !== 0)
|
||||||
{
|
{
|
||||||
|
@ -155,8 +158,12 @@ for(var i in settings)
|
||||||
{
|
{
|
||||||
console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed");
|
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"){
|
// initially load settings
|
||||||
console.warn("DirtyDB is used. This is fine for testing but not recommended for production.")
|
exports.reloadSettings();
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue