forked from svrjs/svrjs
Combine crash handlers in master process into one function.
This commit is contained in:
parent
8af7f1df99
commit
2eedf125a8
1 changed files with 8 additions and 11 deletions
19
svr.js
19
svr.js
|
@ -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) {
|
||||||
|
|
Reference in a new issue