How to reload flow not modified by editor

846 views
Skip to first unread message

Stefano Costa

unread,
Sep 18, 2015, 5:13:58 AM9/18/15
to Node-RED
I need to propagate modifications of a flow to multiple nodered instances.

When I'm editing a flow pushing "deploy" makes modifications take effect immediatly, without restarting nodered (of course). I'm now working at a way for replicating the same flow file (flow.js by default) to several different hosts runnign nodered; I noticed that simply replacing the flow file does not reload it on a running nodered. Any command that I can use for this? Don't want to restart nodered if not strictly needed.

Background: we're building an array of dataloggers based on Raspberry+nodered+MQTT that we will use for a mesh networking validation process (several nodes to be kept under control...), and don't want to manually change flows on tenth of running hosts collecting logs etc.

Thanks!
--
  Stefano Costa
  www.bluewind.it

Nicholas O'Leary

unread,
Sep 18, 2015, 5:15:34 AM9/18/15
to Node-RED Mailing LIst
Hi Stefano,

you can use the same runtime api the editor does when you click the deploy button - do an http post of the new flow to /flows. Documented here: http://nodered.org/docs/api/admin/methods/post/flows/

Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stefano Costa

unread,
Sep 18, 2015, 6:04:50 AM9/18/15
to Node-RED

Many thanks Nicholas, works perfectly. Just as a reference for anyone with similar needs this is a suitable curl:

curl -X POST -d @userdir/flow.js.new http://localhost:1880/flows -H "Content-type: application/json" -H "Node-RED-Deployment-Type: full"

given that the command is issued inside the same host running nodered, the updated/modified flow file is userdir/flow.js.new (relative from currend folder) and no auth is needed from localhost.

The command can be part of a shell script that (example) pulls with git a new flow file, or watches for a file being modified by a mqtt sub pending... full example coming soon on github!
S

Nicholas O'Leary

unread,
Sep 18, 2015, 6:08:43 AM9/18/15
to Node-RED Mailing LIst
fyi - the Node-RED-Deployment-Type header is assumed to be 'full' if not set - you only really need to set it to specify one of the partial deployment types.

N

Stefano Costa

unread,
Sep 23, 2015, 9:46:30 AM9/23/15
to Node-RED

...unfortunately this does not work if used as a command in an "exec" node (flow updating itself), probably because the command is interrutped by itself while reloading...

Nicholas O'Leary

unread,
Sep 23, 2015, 9:47:57 AM9/23/15
to Node-RED Mailing LIst
I believe it's been successfully done use the HTTP Request node

N

On 23 September 2015 at 14:46, Stefano Costa <stefan...@bluewind.it> wrote:

...unfortunately this does not work if used as a command in an "exec" node (flow updating itself), probably because the command is interrutped by itself while reloading...

Stefano Costa

unread,
Sep 28, 2015, 6:44:27 AM9/28/15
to Node-RED


Il giorno mercoledì 23 settembre 2015 15:47:57 UTC+2, Nicholas O'Leary ha scritto:
I believe it's been successfully done use the HTTP Request node

Thanks it works! Now a question related to the same issue: is it possible to "get" configuration information, like (useful here) the port Node Red is listening to? Out of reading settings.js directly of course.
Reply all
Reply to author
Forward
0 new messages