mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 07:57:56 +03:00
meshuser: log uncaught exceptions to mesherrs
This commit is contained in:
parent
ff4c67da7c
commit
ad6ff11413
@ -495,15 +495,19 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
console.log('ERR: ' + datastr);
|
console.log('ERR: ' + datastr);
|
||||||
if (data.startsWith('le.challenges[tls-sni-01].loopback')) { return; } // Ignore this error output from GreenLock
|
if (data.startsWith('le.challenges[tls-sni-01].loopback')) { return; } // Ignore this error output from GreenLock
|
||||||
if (data[data.length - 1] == '\n') { data = data.substring(0, data.length - 1); }
|
if (data[data.length - 1] == '\n') { data = data.substring(0, data.length - 1); }
|
||||||
try {
|
obj.logError(data);
|
||||||
var errlogpath = null;
|
|
||||||
if (typeof obj.args.mesherrorlogpath == 'string') { errlogpath = obj.path.join(obj.args.mesherrorlogpath, 'mesherrors.txt'); } else { errlogpath = obj.getConfigFilePath('mesherrors.txt'); }
|
|
||||||
obj.fs.appendFileSync(errlogpath, '-------- ' + new Date().toLocaleString() + ' ---- ' + getCurrentVersion() + ' --------\r\n\r\n' + data + '\r\n\r\n\r\n');
|
|
||||||
} catch (ex) { console.log('ERROR: Unable to write to mesherrors.txt.'); }
|
|
||||||
});
|
});
|
||||||
childProcess.on('close', function (code) { if ((code != 0) && (code != 123)) { /* console.log("Exited with code " + code); */ } });
|
childProcess.on('close', function (code) { if ((code != 0) && (code != 123)) { /* console.log("Exited with code " + code); */ } });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
obj.logError = function (err) {
|
||||||
|
try {
|
||||||
|
var errlogpath = null;
|
||||||
|
if (typeof obj.args.mesherrorlogpath == 'string') { errlogpath = obj.path.join(obj.args.mesherrorlogpath, 'mesherrors.txt'); } else { errlogpath = obj.getConfigFilePath('mesherrors.txt'); }
|
||||||
|
obj.fs.appendFileSync(errlogpath, '-------- ' + new Date().toLocaleString() + ' ---- ' + getCurrentVersion() + ' --------\r\n\r\n' + err + '\r\n\r\n\r\n');
|
||||||
|
} catch (ex) { console.log('ERROR: Unable to write to mesherrors.txt.'); }
|
||||||
|
};
|
||||||
|
|
||||||
// Get current and latest MeshCentral server versions using NPM
|
// Get current and latest MeshCentral server versions using NPM
|
||||||
obj.getLatestServerVersion = function (callback) {
|
obj.getLatestServerVersion = function (callback) {
|
||||||
if (callback == null) return;
|
if (callback == null) return;
|
||||||
|
@ -555,7 +555,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
if (commandHandler != null) {
|
if (commandHandler != null) {
|
||||||
try { commandHandler(command); return;
|
try { commandHandler(command); return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Unhandled error while processing ' + command.action + ' for user ' + + user.name + ':\n' + e);
|
console.log('Unhandled error while processing ' + command.action + ' for user ' + user.name + ':\n' + e);
|
||||||
|
parent.parent.logError(e.stack);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log('Unknown action from user ' + user.name + ': ' + command.action + '.');
|
// console.log('Unknown action from user ' + user.name + ': ' + command.action + '.');
|
||||||
|
Loading…
Reference in New Issue
Block a user