pass error messages to pad text if shown during startup

This commit is contained in:
John McLear 2015-04-06 00:13:38 +01:00
parent b26956be4b
commit 3a969f8dd8
2 changed files with 24 additions and 4 deletions

View file

@ -27,7 +27,7 @@ var npm = require("npm/lib/npm.js");
var jsonminify = require("jsonminify");
var log4js = require("log4js");
var randomString = require("./randomstring");
var suppressDisableMsg = " -- To suppress these warning messages change suppressErrorsInPadText to true in your settings.json\n";
/* Root path of the installation */
exports.root = path.normalize(path.join(npm.dir, ".."));
@ -54,6 +54,11 @@ exports.ip = "0.0.0.0";
*/
exports.port = process.env.PORT || 9001;
/**
* Should we suppress Error messages from being in Pad Contents
*/
exports.suppressErrorsInPadText = false;
/**
* The SSL signed server key and the Certificate Authority's own certificate
* default case: ep-lite does *not* use SSL. A signed server key is not required in this case.
@ -266,7 +271,11 @@ exports.reloadSettings = function reloadSettings() {
{
fs.exists(exports.abiword, function(exists) {
if (!exists) {
console.error("Abiword does not exist at this path, check your settings file");
var abiwordError = "Abiword does not exist at this path, check your settings file";
if(!exports.suppressErrorsInPadText){
exports.defaultPadText = exports.defaultPadText + "\nError: " + abiwordError + suppressDisableMsg;
}
console.error(abiwordError);
exports.abiword = null;
}
});
@ -275,11 +284,19 @@ exports.reloadSettings = function reloadSettings() {
if(!exports.sessionKey){ // If the secretKey isn't set we also create yet another unique value here
exports.sessionKey = randomString(32);
console.warn("You need to set a sessionKey value in settings.json, this will allow your users to reconnect to your Etherpad Instance if your instance restarts");
var sessionWarning = "You need to set a sessionKey value in settings.json, this will allow your users to reconnect to your Etherpad Instance if your instance restarts";
if(!exports.suppressErrorsInPadText){
exports.defaultPadText = exports.defaultPadText + "\nWarning: " + sessionWarning + suppressDisableMsg;
}
console.warn(sessionWarning);
}
if(exports.dbType === "dirty"){
console.warn("DirtyDB is used. This is fine for testing but not recommended for production.");
var dirtyWarning = "DirtyDB is used. This is fine for testing but not recommended for production.";
if(!exports.suppressErrorsInPadText){
exports.defaultPadText = exports.defaultPadText + "\nWarning: " + dirtyWarning + suppressDisableMsg;
}
console.warn(dirtyWarning);
}
};