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 () {
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();
});

View File

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

View File

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

View File

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