I'm hoping someone might be able to help figure this out. I have Node-RED running on a Windows Server and it is setup as a Windows Service using NSSM (Non-Sucking Service Manager). I was hoping to be able to use an Exec node to run the command nssm restart Node-RED which works as expected when run directly from the command line but it seems to only stop the service when it is run using the Exec node in Node-RED... it never starts the Service back up?
Any ideas as to why this might be and how I might get it to work?
Using an Exec Node - it will fire up a child process of the node process (that Node RED is running under)
The moment nssm kills the node process (to restart it), the child process (in this case nssm) is also being killed - stopping it from starting up node after.
nssm has to stay alive for it to start a new node process - but it cant, becuase it got killed (as it was started from the node process, that is being killed)
At least that is what i think is going on.
I cant be sure, but I think the exec node has options in how process's are started? (i don't is use it much)
try powershell -command "Restart-Service name_of_service -Force" or look into the sc command. alternatively, setup the service to auto restart and simply kill it (let it auto restart)
That said...
this looks like a sledgehammer approach to cracking some problematic nut. Why are you wanting to restart the service anyhow?
We have a UI setup to run our industrial LASER marker and occasionally (rarely) the SQLite database that is used in that flow gets 'locked' (can't figure out what or why) but the only way I've found to fix it is to simply restart Node-RED so that it kills the SQLite node and forces it to reconnect to the DB file.
This being the case, I wanted to add a button to the UI to allow the user to force this when the problem occurs.