I have a small task but it is a bit too tricky for me
I am running a script from an EXEC Node that sometimes failes (once a day).
In these cases I have to find out the ID of this script (using ps -ef | grep python) manually and stop it with a KILL command and simply restart the Script via EXEC Node.
Now I would like to automatize this Auto-Kill and Auto-Restart
I have the ID already in this payload field, now the question is to get exactly this value into a variable
It always has to be the ID before the EVN.py script, but I do not yet know how to read this value.
Do you have a hint for me ?
Use a status node pointed at the exec node.
connect a debug (set to show complete message) - you will find the status value.
Then in a function node, if it starts
pid: then split it on
: and get the value from element
I added the status-node like this:
now it seems that the Raspberry Pi is down and cannot be reached any longer. I have to tell my friend to reboot it
You have created a loop
Start node-red with the
--safe flag to fix it.
When I said
I did NOT mean "connected" - when you setup the status node you "point" it at a node to watch its status.
You don't need the ID. If you send a message into the exec node with
msg.kill set to
true then it will kill the current process. For more information see the help text for the node.
So this one specific EXEC node is always linked to one process ?
What if I trigger the node several times from different sources ?
Which one will be killed if I send a "msg.kill" ?
If you have several instances running at once from the same exec then I guess you will have to provide the PID in
msg.pid. Are you running several instances in parallel? You will also have trouble picking up the PID from the status in that case. How will you know which one is the one giving the problem?