Merge pull request #3 from ranchimall/uncaught-no-shut

hotfix: Do not shutdown on unhandled exceptions
This commit is contained in:
Sai Raj 2023-01-08 17:36:33 +05:30 committed by GitHub
commit e3f5de4df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,12 +212,13 @@ function exitHandler(options, _process, node, err) {
if(err.stack) { if(err.stack) {
log.error(err.stack); log.error(err.stack);
} }
node.stop(function(err) { if(options.exit)
if(err) { node.stop(function(err) {
log.error('Failed to stop services: ' + err); if(err) {
} log.error('Failed to stop services: ' + err);
_process.exit(-1); }
}); _process.exit(-1);
});
} }
// Handle SIGINT (Ctrl+C) // Handle SIGINT (Ctrl+C)
if (options.sigint) { if (options.sigint) {
@ -229,7 +230,7 @@ function exitHandler(options, _process, node, err) {
} }
function registerExitHandlers(_process, node) { function registerExitHandlers(_process, node) {
_process.on('uncaughtException', exitHandler.bind(null, {exit:true}, _process, node)); _process.on('uncaughtException', exitHandler.bind(null, {exit:false}, _process, node));
_process.on('SIGINT', exitHandler.bind(null, {sigint:true}, _process, node)); _process.on('SIGINT', exitHandler.bind(null, {sigint:true}, _process, node));
} }