mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add flow reload admin api
This commit is contained in:
parent
35c4a41d7b
commit
87d77efa57
@ -41,7 +41,8 @@
|
|||||||
|
|
||||||
"api": {
|
"api": {
|
||||||
"flows": {
|
"flows": {
|
||||||
"error-save": "Error saving flows: __message__"
|
"error-save": "Error saving flows: __message__",
|
||||||
|
"error-reload": "Error reloading flows: __message__"
|
||||||
},
|
},
|
||||||
"library": {
|
"library": {
|
||||||
"error-load-entry": "Error loading library entry '__path__': __message__",
|
"error-load-entry": "Error loading library entry '__path__': __message__",
|
||||||
|
@ -32,6 +32,15 @@ module.exports = {
|
|||||||
var flows = req.body;
|
var flows = req.body;
|
||||||
var deploymentType = req.get("Node-RED-Deployment-Type")||"full";
|
var deploymentType = req.get("Node-RED-Deployment-Type")||"full";
|
||||||
log.audit({event: "flows.set",type:deploymentType},req);
|
log.audit({event: "flows.set",type:deploymentType},req);
|
||||||
|
if (deploymentType === 'reload') {
|
||||||
|
redNodes.loadFlows().then(function() {
|
||||||
|
res.status(204).end();
|
||||||
|
}).otherwise(function(err) {
|
||||||
|
log.warn(log._("api.flows.error-reload",{message:err.message}));
|
||||||
|
log.warn(err.stack);
|
||||||
|
res.status(500).json({error:"unexpected_error", message:err.message});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
redNodes.setFlows(flows,deploymentType).then(function() {
|
redNodes.setFlows(flows,deploymentType).then(function() {
|
||||||
res.status(204).end();
|
res.status(204).end();
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
@ -40,4 +49,5 @@ module.exports = {
|
|||||||
res.status(500).json({error:"unexpected_error", message:err.message});
|
res.status(500).json({error:"unexpected_error", message:err.message});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ var log = require("../log");
|
|||||||
|
|
||||||
var promiseDir = nodeFn.lift(mkdirp);
|
var promiseDir = nodeFn.lift(mkdirp);
|
||||||
|
|
||||||
|
var initialFlowLoadComplete = false;
|
||||||
var settings;
|
var settings;
|
||||||
var flowsFile;
|
var flowsFile;
|
||||||
var flowsFullPath;
|
var flowsFullPath;
|
||||||
@ -191,8 +192,11 @@ var localfilesystem = {
|
|||||||
|
|
||||||
getFlows: function() {
|
getFlows: function() {
|
||||||
return when.promise(function(resolve) {
|
return when.promise(function(resolve) {
|
||||||
|
if (!initialFlowLoadComplete) {
|
||||||
|
initialFlowLoadComplete = true;
|
||||||
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
|
log.info(log._("storage.localfilesystem.user-dir",{path:settings.userDir}));
|
||||||
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
log.info(log._("storage.localfilesystem.flows-file",{path:flowsFullPath}));
|
||||||
|
}
|
||||||
fs.readFile(flowsFullPath,'utf8',function(err,data) {
|
fs.readFile(flowsFullPath,'utf8',function(err,data) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
return resolve(JSON.parse(data));
|
return resolve(JSON.parse(data));
|
||||||
|
Loading…
Reference in New Issue
Block a user