Node-red multiple instances

Hi! I followed this guide to get another instance running: duplicate settings file, different port, mapped to different subdomain (nginx). How should I have this start automatically like my primary instance (which was was installed via the pi script, running as a service). Thanks!

Have you thought about asking 'Steve', the author of that website? Looks like he is very active and commented on a question just a few days ago.

Good idea - thanks!

The tutorial references where the node red service start is specified. I am wondering if I can simply duplicate the statement to start the two instances.

If you want to load node-red on startup with a different settings file than the settings.js you will need to edit the file /lib/systemd/system/nodered.service.

un-comment the line ExecStart if not already done and the Environment=”NODE_RED_OTPIONS=-v” line to something like:

Environment="NODE_RED_OPTIONS=-s /home/pi/.node-red/mysettings.js"
# systemd service file to start Node-RED

Description=Node-RED graphical event wiring tool

# Run as normal pi user - change to the user name you wish to run Node-RED as

# define an optional environment file in Node-RED's user directory to set custom variables externally
# uncomment and edit next line if you need an http proxy
# uncomment the next line for a more verbose log output
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'

ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
# Auto restart on crash
# Tag things in the log


You need a service file for each instance. Then you can individually control them, and they will individually restart in the case of crashes.

Do I simply duplicate the "nodered.service" file and enable the same way as during the primary install?

sudo systemctl enable nodered.service

Yes, apart from making whatever changes are necessary to start the right instance, obviously.

Works - thanks!