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,13 +495,17 @@ function CreateMeshCentralServer(config, args) {
|
||||
console.log('ERR: ' + datastr);
|
||||
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); }
|
||||
obj.logError(data);
|
||||
});
|
||||
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' + data + '\r\n\r\n\r\n');
|
||||
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.'); }
|
||||
});
|
||||
childProcess.on('close', function (code) { if ((code != 0) && (code != 123)) { /* console.log("Exited with code " + code); */ } });
|
||||
};
|
||||
|
||||
// Get current and latest MeshCentral server versions using NPM
|
||||
|
@ -555,7 +555,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if (commandHandler != null) {
|
||||
try { commandHandler(command); return;
|
||||
} 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 {
|
||||
// console.log('Unknown action from user ' + user.name + ': ' + command.action + '.');
|
||||
|
Loading…
Reference in New Issue
Block a user