1
0
Fork 0
forked from svrjs/svrjs

Combine crash handlers in master process into one function.

This commit is contained in:
Dorian Niemiec 2024-05-20 17:27:09 +02:00
parent 8af7f1df99
commit 2eedf125a8

19
svr.js
View file

@ -5806,20 +5806,17 @@ function saveConfig() {
// Process event listeners // Process event listeners
if (cluster.isPrimary || cluster.isPrimary === undefined) { if (cluster.isPrimary || cluster.isPrimary === undefined) {
process.on("uncaughtException", function (err) { // Crash handler
// CRASH HANDLER function crashHandlerMaster(err) {
serverconsole.locerrmessage("SVR.JS master process just crashed!!!"); serverconsole.locerrmessage("SVR.JS worker just crashed!!!");
serverconsole.locerrmessage("Stack:");
serverconsole.locerrmessage(generateErrorStack(err));
process.exit(err.errno);
});
process.on("unhandledRejection", function (err) {
// CRASH HANDLER
serverconsole.locerrmessage("SVR.JS master process just crashed!!!");
serverconsole.locerrmessage("Stack:"); serverconsole.locerrmessage("Stack:");
serverconsole.locerrmessage(err.stack ? generateErrorStack(err) : String(err)); serverconsole.locerrmessage(err.stack ? generateErrorStack(err) : String(err));
process.exit(err.errno); process.exit(err.errno);
}); }
process.on("uncaughtException", crashHandlerMaster);
process.on("unhandledRejection", crashHandlerMaster);
process.on("exit", function (code) { process.on("exit", function (code) {
try { try {
if (!configJSONRErr && !configJSONPErr) { if (!configJSONRErr && !configJSONPErr) {