Running Multiple Instances of Node-red using NSSM

Continuing the discussion from Node red multiple instances:

I ran through this entire thread, but unable to start second service for Node-Red
One is running successfully, other doesn't start.

the message says ' the service did not return an error' could be internal or windows error .

what arguments should i pass in the NSSM ?

Assuming you setup your folders like described in that thread (a few posts above the one you linked to) (this post) then you would set your NSSM commands to run each instance in the same way as if you were running it from a cmd window

example...

NSSM1: node-red -p 1880 -u c:/node-red-1880
NSSM2: node-red -p 1881 -u c:/node-red-1881
NSSM3: node-red -p 1882 -u c:/node-red-1882

etc etc

Just be sure that the account that runs the NSSM service has read/write access to these folders.

I am sorry, my first service which is successfully running, is not in this format,
this is what i have in first service

Path: c:\Users\oee\AppData\Roaming\npm\node-red.cmd
Startup directory : c:\users\oee\.node-red
Arguments : -u c:\users\oee\.node-red > c:\temp\node-red.log

so i don't know where to put the second service

i am running second instance successfully from command window by using this command

node-red  -userDir c:\Users\oee2\.node-red2 second.json

in second settings file, i have put 1881 as the port address

So use that command in your second NSSM service.

Note. I don't recommend this setup. If user oee2 is removed or locked out you can lose work.

The folder format & commands I linked 2 is far more obvious, user friendly and safe.

It is of course up to you how you arrange things.

1 Like

sorry for being a noob.

should i put this command in Path or Arguments in edit nssm window ?

node-red -userDir c:\Users\oee2\.node-red2 second.json

i tried in both, but not working.

however, there is no error. just that i cant access the 1881 port from browser, says Lost connection

EDIT : It started working, the setting was fine, just there was a huge delay in actual starting the service.

Path : <same as service 1>
Startup Directory : Second Folder (Same User)
Arguments : -userDir c:\users\<same user as service1>\<second folder> second.json > c:\temp\node-red2.log

I dont know but it is having a huge delay. (3 minutes)
attaching log below may be you can help me understand if there is any issue.
taking 3 minutes to load pallet nodes (or start loading?)

there is a delay in my first service also, but that was a bigger flow file, so i had assumed the delay is natural. but this second flow is very small

24 Jan 15:40:59 - [info] Windows_NT 10.0.19042 x64 LE
24 Jan 15:44:09 - [info] Loading palette nodes

24 Jan 15:40:59 - [info] 

Welcome to Node-RED
===================

24 Jan 15:40:59 - [info] Node-RED version: v2.1.4
24 Jan 15:40:59 - [info] Node.js  version: v14.17.3
24 Jan 15:40:59 - [info] Windows_NT 10.0.19042 x64 LE
24 Jan 15:44:09 - [info] Loading palette nodes
24 Jan 15:44:11 - [info] Settings file  : c:\users\oee.Hosur\.node-red2\settings.js
24 Jan 15:44:11 - [info] Context store  : 'default' [module=memory]
24 Jan 15:44:11 - [info] User directory : c:\users\oee.Hosur\.node-red2
24 Jan 15:44:11 - [warn] Projects disabled : editorTheme.projects.enabled=false
24 Jan 15:44:11 - [info] Flows file     : C:\Users\OEE.Hosur\.node-red2\db.json
24 Jan 15:44:11 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

24 Jan 15:44:11 - [info] Server now running at http://127.0.0.1:1881/
24 Jan 15:44:11 - [info] Starting flows

If you set the log level to trace in settings.js then it will show more information when loading the nodes. Probably something is holding up the initialisation of one of the nodes. Possibly a network timeout or something.

1 Like

Thanks,

Funny that i changed the "info" to "trace" in log settings and now it is loading instantly !
within 20 seconds from earlier 3 minutes

so if it is an external factor, it may repeat again, but i can live with that..

Thanks for the Help.

The 3 minute delay can be caused by a known issue if your node-red instance does not have an internet connection or is behind a proxy...

Wow, really. Indeed the PC which runs my node red flows does not have continuous internet, it is connected to the modbus TCP server through LAN where it collects sensor data (with no internet). I was connecting it as and when required to download some nodes or copying the outputs to post in this forum.

Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.