diff --git a/packages/node_modules/node-red/red.js b/packages/node_modules/node-red/red.js index 05dc1a0bf..552856167 100755 --- a/packages/node_modules/node-red/red.js +++ b/packages/node_modules/node-red/red.js @@ -429,11 +429,20 @@ httpsPromise.then(function(startupHttps) { process.exit(1); }); - process.on('SIGINT', function () { + function exitWhenStopped() { RED.stop().then(function() { process.exit(); }); + } + process.on('SIGINT', exitWhenStopped); + process.on('SIGTERM', exitWhenStopped); + process.on('SIGHUP', exitWhenStopped); + process.on('SIGUSR2', exitWhenStopped); // for nodemon restart + process.on('SIGBREAK', exitWhenStopped); // for windows ctrl-break + process.on('message', function(m) { // for PM2 under window with --shutdown-with-message + if (m === 'shutdown') { exitWhenStopped() } }); + }).catch(function(err) { console.log("Failed to get https settings: " + err); });