When working with a standard ssh terminal, this command ensures that this daemon continues to work in the background even the ssh terminal is closed after executing the command.
If node-red is stopped after executing the daemon with exec node, the daemon also stops?
I need help on how to make this execution persistent?
Thank you for your reply.
I'm sorry. I wasn't clear enough with my question.
Nodered.service is already persistent against reboots. I need the daemon executed by the Node_red exec node to be persistent even after a Node-Red stop. (By the way Node-Red stop is not caused by a any hardware shutdown)
Node-Red utilizing the exec node executes the above command perfectly and openvpn daemon starts to work. No problem. However the daemon stops abruptly when node-red is stopped.
When I execute the above command from a terminal, it works. Daemon doesn't stop even if I close the terminal.
possible workaround: perhaps have the exec node invoke a screen session to pseud-encapsulate the launch of the daemon so it isn't dependent on node-red's shell session?
Are you using "spawn" mode in your exec node? (not sure if that will help, however)
Also, I've not tried it, but there is another related node in the flows library, called node-red-node-daemon -- although I would think that a node-red server restart would still lose its connection to any process it started...
when the Node-RED exit it closes the flow - which in this case (and for the daemon node) calls kill on the child process. If you need it to run independent of Node-RED you may be able to call it via another shell command (as suggested above) - or just start it outside of Node-RED altogether.
@shrickus I'm not using "spawn" mode. I tried "node-red-node-daemon" but it didn't help.
@dceejay I tried the bash script option (put the command in a bash script and execute it via exec node). I also tried using "nohub command &" to detach the process. But these didn't work out. I'll find another way to start it outside of Node-RED as you suggested.
I am having the exact same use case and I can’t find a way to get it to work other than maybe scheduling the command via crontab.
The exec command shall execute a script that shuts down nodered to free the serial connection, then flashes the Arduino and then starts nodered as service again.
I tried nohup and & for the commands inside the script and to start the script itself but nothing helps to have the process running in its own parent process.
So if you wanted to shell something out, you would put the system call inside that code? Am I understanding that correctly?
In my case, I'm making a system call to VLC to record a show from my HDHR, but I discovered that if I redeploy during the recording, the process gets killed and I just want to avoid that.