mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix credential pruning and start/stop log messages
This commit is contained in:
parent
fbb45a8961
commit
f3880b7601
@ -301,7 +301,6 @@ Flow.prototype.start = function() {
|
||||
if (this.missingTypes.length > 0) {
|
||||
throw new Error("missing types");
|
||||
}
|
||||
|
||||
events.emit("nodes-starting");
|
||||
|
||||
for (var id in this.nodes) {
|
||||
@ -435,7 +434,13 @@ Flow.prototype.applyConfig = function(config,type) {
|
||||
}
|
||||
|
||||
var flow = this;
|
||||
if (type != "full") {
|
||||
log.info("Stopping modified "+type);
|
||||
}
|
||||
return this.stop(activeNodesToStop).then(function() {
|
||||
if (type != "full") {
|
||||
log.info("Stopped modified "+type);
|
||||
}
|
||||
flow.parseConfig(config);
|
||||
for (var i=0;i<nodesToRewire.length;i++) {
|
||||
var node = flow.activeNodes[nodesToRewire[i]];
|
||||
@ -443,7 +448,13 @@ Flow.prototype.applyConfig = function(config,type) {
|
||||
node.updateWires(flow.allNodes[node.id].wires);
|
||||
}
|
||||
}
|
||||
if (type != "full") {
|
||||
log.info("Starting modified "+type);
|
||||
}
|
||||
flow.start();
|
||||
if (type != "full") {
|
||||
log.info("Started modified "+type);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
credentialCache[nodeID] = savedCredentials;
|
||||
delete node.credentials;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -75,45 +75,6 @@ var flowNodes = module.exports = {
|
||||
activeFlow.eachNode(cb);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops all active nodes and clears the active set
|
||||
* @return a promise for the stopping of all active nodes
|
||||
*/
|
||||
//clear: function(nodesToStop) {
|
||||
// var stopList;
|
||||
// if (nodesToStop == null) {
|
||||
// stopList = Object.keys(nodes);
|
||||
// } else {
|
||||
// stopList = Object.keys(nodesToStop);
|
||||
// }
|
||||
// console.log(stopList);
|
||||
// return when.promise(function(resolve) {
|
||||
// events.emit("nodes-stopping");
|
||||
// var promises = [];
|
||||
// console.log("running nodes:",Object.keys(nodes).length);
|
||||
// for (var i=0;i<stopList.length;i++) {
|
||||
// var node = nodes[stopList[i]];
|
||||
// if (node) {
|
||||
// try {
|
||||
// var p = node.close();
|
||||
// if (p) {
|
||||
// promises.push(p);
|
||||
// }
|
||||
// } catch(err) {
|
||||
// node.error(err);
|
||||
// }
|
||||
// delete nodes[stopList[i]];
|
||||
// delete activeConfigNodes[stopList[i]];
|
||||
// }
|
||||
// }
|
||||
// console.log("running nodes:",Object.keys(nodes).length);
|
||||
// when.settle(promises).then(function() {
|
||||
// events.emit("nodes-stopped");
|
||||
// resolve();
|
||||
// });
|
||||
// });
|
||||
//},
|
||||
|
||||
/**
|
||||
* @return the active configuration
|
||||
*/
|
||||
@ -135,7 +96,12 @@ var flowNodes = module.exports = {
|
||||
|
||||
var credentialSavePromise = null;
|
||||
|
||||
config.forEach(function(node) {
|
||||
|
||||
// Clone config and extract credentials prior to saving
|
||||
// Original config needs to retain credentials so that flow.applyConfig
|
||||
// knows which nodes have had changes.
|
||||
var cleanConfig = clone(config);
|
||||
cleanConfig.forEach(function(node) {
|
||||
if (node.credentials) {
|
||||
credentials.extract(node);
|
||||
credentialsChanged = true;
|
||||
@ -148,22 +114,22 @@ var flowNodes = module.exports = {
|
||||
credentialSavePromise = when.resolve();
|
||||
}
|
||||
|
||||
|
||||
if (type=="full") {
|
||||
return credentialSavePromise
|
||||
.then(function() { return storage.saveFlows(config);})
|
||||
.then(function() { return flowNodes.stopFlows(); })
|
||||
.then(function() { activeFlow = new Flow(config); flowNodes.startFlows();});
|
||||
.then(function() { return storage.saveFlows(cleanConfig);})
|
||||
.then(function() { return flowNodes.stopFlows(); })
|
||||
.then(function() { activeFlow = new Flow(config); flowNodes.startFlows();});
|
||||
} else {
|
||||
return credentialSavePromise
|
||||
.then(function() { return storage.saveFlows(config);})
|
||||
.then(function() { return activeFlow.applyConfig(config,type); });
|
||||
.then(function() { return storage.saveFlows(cleanConfig);})
|
||||
.then(function() { return activeFlow.applyConfig(config,type); });
|
||||
}
|
||||
},
|
||||
startFlows: function() {
|
||||
log.info("Starting flows");
|
||||
try {
|
||||
activeFlow.start();
|
||||
log.info("Started flows");
|
||||
} catch(err) {
|
||||
var missingTypes = activeFlow.getMissingTypes();
|
||||
if (missingTypes.length > 0) {
|
||||
@ -177,7 +143,10 @@ var flowNodes = module.exports = {
|
||||
},
|
||||
stopFlows: function() {
|
||||
log.info("Stopping flows");
|
||||
return activeFlow.stop();
|
||||
return activeFlow.stop().then(function() {
|
||||
log.info("Stopped flows");
|
||||
return;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user