1

Node-RED has very nice "single-click deployment" feature. Using this feature, node-red deploys all its nodes and flows very quickly.

However, I would like to know - where flows and nodes ,we develop in Node-RED editor, are deployed when we click "deploy" button in the node-RED? The reason why I am asking because I would like to deploy Node-RED's generated code ( I guess it is in Node.js) on remote devices (e.g., Android) automatically.

I know one of solution to connect is -- run MQTT publisher on Android device and write subscriber in MQTT subscriber in NodeRED to get event data. But, the problem with this solution is - manual deployment (time consuming, error prone).

As Tiago has suggested in the answer section of this question, Node-RED generates JSON files in the useDir according to nodes and flows we define in the Node-RED editor. Can we get node.js files, instead of JSON files ? This would help us to deploy device specific code on each device without loading Node-RED editor on each device?

user-517752
  • 1,188
  • 5
  • 21
  • 54
  • Following your update in response to Tiago's answer, this is essentially a feature request not a question about how to use Node-RED. This is better asked on the project's mailing list - StackOverflow isn't the place for it. – knolleary Nov 22 '15 at 21:34
  • 1
    @Pankesh just so you know you can disable the editor on settings file. See disableEditor: http://nodered.org/docs/configuration.html – Tiago Lopo Nov 23 '15 at 10:14
  • @Tiago : Thanks for the information ! – user-517752 Nov 23 '15 at 16:03

1 Answers1

2

You can copy your userDir on those remote devices and launch node-red:

Your flows as well as your settings file is there:

# /opt/node/bin/node-red -help 
Node-RED v0.12.1
Usage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR] [flows.json]

Options:
  -s, --settings FILE  use specified settings file
  -u, --userDir  DIR   use specified user directory
  -v                   enable verbose output
  -?, --help           show usage

My userDir:

root@arm:~# find /root/.node-red/
/root/.node-red/
/root/.node-red/lib
/root/.node-red/lib/flows
/root/.node-red/settings.js
/root/.node-red/flows_arm.json
/root/.node-red/.config.json
/root/.node-red/.flows_arm.json.backup

BTW your flow is just a json file, take a look at it I'm sure you understand how it works :)

Tiago Lopo
  • 7,619
  • 1
  • 30
  • 51
  • Thanks for the answer ! But, the problem with your solution is that each device would load the same application. Right ? (Please feel free to correct me) The way I see the node-RED application is -- it contains nodes and connections between them. Each node should be deployed individually on each individual device and they talk with each other through some communication protocol (e.g., MQTT). So, I would like to deploy one node, rather than whole application on a single device. – user-517752 Nov 21 '15 at 11:32
  • Yeah those devices would run the same app, I thought it was what you were after. But what I think you're confused about what a node is. are you writing your own nodes or just dragging and dropping from the left side pane? http://nodered.org/docs/creating-nodes/first-node.html – Tiago Lopo Nov 21 '15 at 12:06
  • The way I see Node-RED is (Please feel free to correct me!) - It provides drag-and-drop interface to write `node.js` application. For instance, I have to write 50 lines of code using node.js to just develop MQTT subsriber. This functionality is possible in Node-RED is just by dragging MQTT input node in the node-RED editor. So, I am looking for a solution that generates Node.js code simply by dragging a small block. If I could get generated node.js code then, I can write a script that deploy the code on device automatically, rather than loading Node-RED editor on each device. – user-517752 Nov 21 '15 at 12:12
  • 1
    node-red is a frame work to wire things together... once you create your flow using the gui it does not automatically create node.js code for you, it creates a json file that can be interpreted by node-red which runs on top of nodejs, does that make sense? you can create and test you node-red app in your laptop and deploy it in whatever device which supports nodejs. – Tiago Lopo Nov 21 '15 at 13:01
  • @Pankesh I would think NodeRed framework would greatly ease this. I'm also after the same feature, I am not sure it exists though but. It should be possible to do it. – Alexandre Dumont Aug 07 '17 at 13:07