Installing Node-RED on the RoadRunner

Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click. This article explain how to instal and use it the Roadrunner board

Installation

To install Node-RED on the Roadrunner board type these command at Linux prompt to install first Node.js:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

and then the latest version of Node-RED:

sudo npm install -g --unsafe-perm node-red

When finished type:

node-red 

to launch it open your browser at this page:

All the working file related to this instance of Node-RED will be save inside the directory .node-red.

The file ~/.node-red/settings.js can be changed to change for example the port used by Node-RED or to protect the access on it via web.

Launch automatically Node-RED at startup using Systemd

If your user name is for example acme create file like this:

[Unit]
Description=Node-RED 
After=syslog.target network.target

[Service]
ExecStart=/usr/bin/node-red 
WorkingDirectory=/acme
User=acme
Group=acme
Nice=10
SyslogIdentifier=Node-RED
StandardOutput=syslog
Restart=on-failure
# Node-RED need a SIGINT to be notified to stop
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

then save it in /lib/systemd/system/node-red.service and type these commands:

sudo systemctl daemon-reload
sudo systemctl enable node-red
sudo systemctl start node-red

It is possible to check any errors by checking the log file:

sudo journalctl -f -u node-red -o cat

Protect the access at Node-RED page

Install node-red-admin by typing:

sudo npm install -g node-red-admin

Create a password hash:

node-red-admin hash-pw

add these lines in .node-red/settings.js inside the module.exports session:

module.exports = {
    adminAuth: {
        type: "credentials",
        users: [{
            username: "admin",
            password: "put the password hash here",
            permissions: "*"
        }]
    },

Restart NodeRED:

sudo systemctl restart node-red.service

Enable the github content manager

Install git by typing:

sudo apt-get update
sudo apt-get install git

launch nano to edit the file setting.js:

sudo nano .node-red/settings.js

change this section:

    editorTheme: {
       projects: {
           enabled: false
       }
    },

in:

    editorTheme: {
       projects: {
           enabled: true
       }
    },

Restart NodeRED:

sudo systemctl restart node-red.service

Check for any errors at NodeRED startup:

sudo journalctl -f -u node-red -o cat

Links

Sergio Tanzilli
System designer, software developer and company co-founder
tanzilli@acmesystems.it
Webpages: https://www.acmesystems.it and http://www.tanzolab.it
Github repository: https://github.com/tanzilli and https://github.com/acmesystems