Alternate-node-red-installer

Hello, today i try the alternate-node-red-installer by TotallyInformation. My goal at the end is, to have different instances with the same version of node-red. aner later use nginx to manage it all

Unfortnely i cant get it run. I (tried) to follow this guide https://github.com/TotallyInformation/alternate-node-red-installer/blob/master/README.md.
I am pretty sure i missunderstand some things

  1. I used nrinstall -f ~/nrtest. Now i have a folder /home/user/nrtest. There i have a subfolder called data. But what now? i am kinda confused how to create now multiple instances with different ports.

Should i create a new folder /home/user/nrtest/node-red-1881 and run in this folder npm install --unsafe-perm --production node-red ?

Sorry i am to dumb to understand this guide.

If all the node red instances use the same version of node red then you don't need the alternate installer. You can start node red using command line parameters to tell it where to get its flows and settings file and what port to use. Not at my computer so can't confirm exactly what, but probably this will tell you
node-red --help

The normal NR installer creates one instance in a .node-red folder

The alternate installer lets you create extra instances - all of them separate from each other and not sharing things like settings or version numbers

So, I don't think alternate installer is what your looking for - Colin's advice looks the way forward for you

What @cymplecy and @Colin state are correct, you can create multiple instances simply by providing the correct command line options. There are even threads on the forum detailing how you can do this.

An alternative to consider is using a tool that does it all for you from a web based frontend. There are several out there, one such offering is FlowFuse.

Take 5 mins and watch this Why FlowFuse video.

If you think it could be useful for you to have a single web based portal for stopping, starting, creating all your node-reds, then go ahead and give it a go. It's free if you install it yourself!

There are multiple options for you to chose. Here are the 2 simplest options

  • Install it and run it yourself (it is open source, just like Node-RED): Local Install • FlowFuse Docs
  • Or you can skip all that and just dive straight in to a ready made, secured FlowFuse environment (just sign up): FlowForge

Full disclosure, I work for FlowFuse (and I am a Node-RED core developer too).

Thank you.

I know that this multiple instances was discussed very often. But i still dont get it quiet well.

I know that there are parameters that will point to a dir and/or to a port.

For example: home/user/.node-red (created through the „original“ script)
home/user/.node-red-1881

So i can start node red pointing to dir. .node-red and port 1880 AND start another instance
pointing to .node-red-1881 and port 1881

(To make it boot on start is another question, but i am not there yet)

Is it enouth to just copy .node-red directory and name it node-red-1881. and there i change the settings.js to the right port (here 1881)?

There is no need to copy the .node-red directory. Just create the 2nd node-red directory and start node-red with the right command line and node-red will create the new instance and a brand new settings.js for you.

If you want to! but it is not really necessary if you set the port in the command line.

thank you all.

So i can use bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) to create node red as my main instance.

than (in there) i can copy the settings.js, name it for example settings1881.js.

now i have in there 2 settingsfiles: settings.js and settings1881.js.

I then editied settings1881.js and changed the name of the flows file

Can you help me here a bit more please. I guess u changed uiPort: process.env.PORT || 1880, to uiPort: process.env.PORT || 1881 (for emxample).
What do you mean with "changes the name of the flow files"

thank you

Not quite. This installs the core of node-red. You dont have any instances until you start node-red.

This is NOT necessary.

No, dont do that.

See this: Node red multiple instances - #7 by Steve-Mcl

Ignore me - follow @Steve-Mcl advice - too many cooks spoil the broth :slight_smile:

thanks again to all for the help.

I try to sum-up what did, maybe this will help another one:

What i ve done now. I used bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) to install/create the core version of node-red.

Now i have a "main" folder called .node-red. So far so good.
Now i created a second folder .node-red-1881.

From my undertanding, nothing is running (yet)

I used the command (linux) that u all sugested:
node-red -p 1880 -u /root/.node-red
AND
node-red -p 1881 -u /root/.node-red-1881

again. from my understanding and like steve mentioned, there should now 2 independent instances of node red.
And yes, i can confirm that there are 2 versions now.

My plan now:
Since the instances are only runnig as long my shell is opened i (you) now have to make node-red running in the backround and on start up.

Why are you using root?
What platform are you running on? (Pi?, Windows? Mac?)

I am on a VM (Debian)

best regards

to start multiple insnaces start on startup, is there a specifc guide to fullfill this you yould recommend?

thank you

Have you read the documentation Running on Raspberry Pi : Node-RED?
Take a look at the Running as a service section and see if that will work for you.

thank you.

Yes i know how to settle it at reboot for 1880. I always used:
sudo systemctl enable nodered.service

I struggle to find the bridge for all other ports. I tried to copy the nodered.service file and name it nodered1881.service, but i am lost on how to continue.

best regards

For everyone thah has the same trouble as me:

I followed this guide. I am now able to have 2 instances and run them as a service on boot:

Now i am trying to marry nginx with it.

As the others have said, the alt installer isn't actually needed for this. Rather, it allows you to have totally intependent versions of node-red running in their own folder structures and without the need to install globally (which requires sudo and can have negative security implications in a production service).

If you want the best of both worlds (a single instance of Node-RED source plus the local install benefits), that can also be done with the alt installer. All you need is to create more than just the data folder that was created for you. For example, you could create a data-prod and data-dev folder. Then you can copy the systemd startup script and change the parameters to use the different userDir folder and port.

NGINX can be used as a reverse proxy in either case.

That is a completely encapsulated instance of Node-RED and the data sub-folder is the userDir folder that in a default Node-RED installation would be at ~/.node-red. Just change the port number if you already have an existing node-red instance running. There is an example settings.js file that you can use that somewhat expands and improves on Node-RED's default file giving you more options on doing things like setting ports using environment variables.

To run it, you should see an npm script that lets you do npm start to run up the instance manually. There is an example systemd script included that you can link across into your systemd scripts area, just change it to your own needs. It should be well documented inside the script. That example script includes the optional link to a local environment file - that will set env variables at startup - so again, you can control things like the Node-RED port there. The file lives in the same folder structure so that, again, it doesn't have to be edited using sudo.

No, you don't need any other folders. That is the purpose of the alternate installer. It creates a fully encapsulated installation of Node-RED without needing sudo or other admin privileges or other folders. All in 1 place for ease of backup, copy, etc.

In context, the OP is referring to the userDir not the core node-red install code. To have multiple instances that dont "interfere" with each other, then separate userDirs are required*.

*require: yes, the OP could have multiple settings files and individually named flows etc but the node modules would be shared - that sounds cool & all, but it can be a headache when a) some nodes are not needed in other instance and updating nodes require all instances to restart.

1 Like

Yes, I know. I covered both in my reply. See "If you want the best of both worlds ..."

1 Like

Thanks again. with all of your help, i managed it to get
multiple instances that are SSL certificated and are managed by nginx.

I will write a guide how i did it for future references

3 Likes