1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

catch mode signals to allow clean context flush on shutdown

(yes the name is intentionally ironic)
Code pattern copied from https://nodejs.org/api/process.html#process_signal_events
This commit is contained in:
Dave Conway-Jones 2020-01-31 18:11:58 +00:00
parent 6b52206186
commit fcf757f715
No known key found for this signature in database
GPG Key ID: 302A6725C594817F

View File

@ -342,8 +342,14 @@ process.on('uncaughtException',function(err) {
process.exit(1);
});
process.on('SIGINT', function () {
function brexit() {
RED.stop().then(function() {
process.exit();
});
});
}
process.on('SIGINT', brexit);
process.on('SIGTERM', brexit);
process.on('SIGHUP', brexit);
process.on('SIGUSR2', brexit); // for nodemon restart
process.on('SIGBREAK', brexit); // for windows ctrl-break