mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Partial deploy with missing node type breaks deploy
This commit is contained in:
parent
4078212089
commit
af20f3df64
@ -253,6 +253,7 @@ function Flow(config) {
|
||||
|
||||
this.activeNodes = {};
|
||||
this.subflowInstanceNodes = {};
|
||||
this.catchNodeMap = {};
|
||||
this.started = false;
|
||||
|
||||
this.parseConfig(config);
|
||||
@ -273,8 +274,6 @@ Flow.prototype.parseConfig = function(config) {
|
||||
|
||||
this.configNodes = {};
|
||||
|
||||
this.catchNodeMap = null;
|
||||
|
||||
var unknownTypes = {};
|
||||
|
||||
for (i=0;i<this.config.length;i++) {
|
||||
@ -352,7 +351,16 @@ Flow.prototype.parseConfig = function(config) {
|
||||
this.missingTypes = Object.keys(unknownTypes);
|
||||
}
|
||||
|
||||
Flow.prototype.start = function() {
|
||||
Flow.prototype.start = function(configDiff) {
|
||||
if (configDiff) {
|
||||
for (var i=0;i<configDiff.rewire.length;i++) {
|
||||
var node = flow.activeNodes[configDiff.rewire[i]];
|
||||
if (node) {
|
||||
node.updateWires(flow.allNodes[node.id].wires);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.started = true;
|
||||
if (this.missingTypes.length > 0) {
|
||||
throw new Error("missing types");
|
||||
@ -402,8 +410,14 @@ Flow.prototype.start = function() {
|
||||
events.emit("nodes-started");
|
||||
}
|
||||
|
||||
Flow.prototype.stop = function(nodeList) {
|
||||
nodeList = nodeList || Object.keys(this.activeNodes);
|
||||
Flow.prototype.stop = function(configDiff) {
|
||||
var nodeList;
|
||||
|
||||
if (configDiff) {
|
||||
nodeList = configDiff.stop;
|
||||
} else {
|
||||
nodeList = Object.keys(this.activeNodes);
|
||||
}
|
||||
var flow = this;
|
||||
return when.promise(function(resolve) {
|
||||
events.emit("nodes-stopping");
|
||||
@ -481,15 +495,12 @@ Flow.prototype.applyConfig = function(config,type) {
|
||||
//}
|
||||
|
||||
var nodesToStop = [];
|
||||
var nodesToCreate = [];
|
||||
nodesToRewire = diff.wiringChanged;
|
||||
|
||||
if (type == "nodes") {
|
||||
nodesToStop = diff.deleted.concat(diff.changed);
|
||||
nodesToCreate = diff.changed;
|
||||
} else if (type == "flows") {
|
||||
nodesToStop = diff.deleted.concat(diff.changed).concat(diff.linked);
|
||||
nodesToCreate = diff.changed.concat(diff.linked);
|
||||
}
|
||||
|
||||
for (var i=0;i<nodesToStop.length;i++) {
|
||||
@ -504,29 +515,12 @@ Flow.prototype.applyConfig = function(config,type) {
|
||||
activeNodesToStop = Object.keys(this.activeNodes);
|
||||
}
|
||||
|
||||
var flow = this;
|
||||
if (type != "full") {
|
||||
log.info("Stopping modified "+type);
|
||||
return {
|
||||
type: type,
|
||||
stop: activeNodesToStop,
|
||||
rewire: nodesToRewire,
|
||||
config: config
|
||||
}
|
||||
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]];
|
||||
if (node) {
|
||||
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);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Flow.prototype.diffFlow = function(config) {
|
||||
|
@ -122,14 +122,28 @@ var flowNodes = module.exports = {
|
||||
} else {
|
||||
return credentialSavePromise
|
||||
.then(function() { return storage.saveFlows(cleanConfig);})
|
||||
.then(function() { return activeFlow.applyConfig(config,type); });
|
||||
.then(function() {
|
||||
var configDiff = activeFlow.applyConfig(config,type);
|
||||
return flowNodes.stopFlows(configDiff).then(function() {
|
||||
activeFlow.parseConfig(config);
|
||||
flowNodes.startFlows(configDiff);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
startFlows: function() {
|
||||
startFlows: function(configDiff) {
|
||||
if (configDiff) {
|
||||
log.info("Starting modified "+configDiff.type);
|
||||
} else {
|
||||
log.info("Starting flows");
|
||||
}
|
||||
try {
|
||||
activeFlow.start();
|
||||
activeFlow.start(configDiff);
|
||||
if (configDiff) {
|
||||
log.info("Started modified "+configDiff.type);
|
||||
} else {
|
||||
log.info("Started flows");
|
||||
}
|
||||
} catch(err) {
|
||||
var missingTypes = activeFlow.getMissingTypes();
|
||||
if (missingTypes.length > 0) {
|
||||
@ -140,11 +154,19 @@ var flowNodes = module.exports = {
|
||||
}
|
||||
}
|
||||
},
|
||||
stopFlows: function() {
|
||||
stopFlows: function(configDiff) {
|
||||
if (configDiff) {
|
||||
log.info("Stopping modified "+configDiff.type);
|
||||
} else {
|
||||
log.info("Stopping flows");
|
||||
}
|
||||
if (activeFlow) {
|
||||
return activeFlow.stop().then(function() {
|
||||
return activeFlow.stop(configDiff).then(function() {
|
||||
if (configDiff) {
|
||||
log.info("Stopped modified "+configDiff.type);
|
||||
} else {
|
||||
log.info("Stopped flows");
|
||||
}
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user