Bit more of a shuffle round of the shutdown handling

This commit is contained in:
Nicholas O'Leary 2013-10-13 19:14:39 +01:00
parent e60120f7c9
commit eb9b31a21b
4 changed files with 17 additions and 10 deletions

3
red.js
View File

@ -72,6 +72,7 @@ process.on('uncaughtException',function(err) {
process.on('SIGINT', function () { process.on('SIGINT', function () {
RED.stop(); RED.stop();
util.log('[red] Exiting Node-RED. Thank you.'); // TODO: need to allow nodes to close asynchronously before terminating the
// process - ie, promises
process.exit(); process.exit();
}); });

View File

@ -271,16 +271,17 @@ module.exports.getNode = function(nid) {
return registry.get(nid); return registry.get(nid);
} }
module.exports.closedown = function() { function stopFlows() {
util.log("[red] Closing Down Nodes");
registry.clear();
}
module.exports.setConfig = function(conf) {
if (activeConfig&&activeConfig.length > 0) { if (activeConfig&&activeConfig.length > 0) {
util.log("[red] Stopping flows"); util.log("[red] Stopping flows");
} }
registry.clear(); registry.clear();
}
module.exports.stopFlows = stopFlows;
module.exports.setConfig = function(conf) {
stopFlows();
activeConfig = conf; activeConfig = conf;
parseConfig(); parseConfig();
} }

View File

@ -33,10 +33,10 @@ var RED = {
}, },
start: server.start, start: server.start,
stop: server.stop,
nodes: nodes, nodes: nodes,
library: library, library: library,
events: events, events: events
stop: nodes.closedown,
}; };
RED.__defineGetter__("app", function() { return server.app }); RED.__defineGetter__("app", function() { return server.app });

View File

@ -101,9 +101,14 @@ function start() {
}); });
} }
function stop() {
redNodes.stopFlows();
}
module.exports = { module.exports = {
init: createServer, init: createServer,
start: start start: start,
stop: stop
} }
module.exports.__defineGetter__("app", function() { return app }); module.exports.__defineGetter__("app", function() { return app });