First here is another way to kill only your one specific process that can be chained:
[{"id":"d6c16e01.a6f6a8","type":"inject","z":"20693e98.c7fb2a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":80,"wires":[["183c2cfc.9db16b"]]},{"id":"183c2cfc.9db16b","type":"exec","z":"20693e98.c7fb2a","command":"","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":450,"y":80,"wires":[[],[],[]]},{"id":"235a9087.df7c","type":"inject","z":"20693e98.c7fb2a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":140,"wires":[["20d208f2.12a6b"]]},{"id":"20d208f2.12a6b","type":"change","z":"20693e98.c7fb2a","name":"set to pid","rules":[{"t":"set","p":"payload","pt":"msg","to":"pid","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":140,"wires":[["790a721f.565ee4"]]},{"id":"790a721f.565ee4","type":"exec","z":"20693e98.c7fb2a","command":"kill ","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":490,"y":140,"wires":[[],[],[]]},{"id":"c12b76ce.692f38","type":"status","z":"20693e98.c7fb2a","name":"","scope":["183c2cfc.9db16b"],"x":160,"y":200,"wires":[["2cc3e208.46e966"]]},{"id":"2cc3e208.46e966","type":"function","z":"20693e98.c7fb2a","name":"get pid","func":"if(msg.status.text){\n let pid = msg.status.text.split(':');\n msg.payload = pid[1];\n return msg;\n} else {\n return null;\n}","outputs":1,"noerr":0,"x":320,"y":200,"wires":[["8a7f851b.b5f7a"]]},{"id":"8a7f851b.b5f7a","type":"change","z":"20693e98.c7fb2a","name":"","rules":[{"t":"set","p":"pid","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":200,"wires":[[]]}]
You can use a status node to get the Process Id of a specific process und use that to just kill that one. Here the status node watches the top exec and saves it to flow.pid which in turn gets appended to the kill command.
Secondly yes you can chain multiple execs behind each other. You can even send the command for the second exec node in the msg object for the first. just put the command for the second exec node in some msg property like msg.secondCommand
and than use a change node after the first exec to move this to msg.payload
.
So in your case set the msg.payload to the pid and for example msg.text to your text you want to append to your python script. Pass this to the first exec with append msg.payload selected and the kill command. After this exec place a change node which moves msg.text to msg.payload and than the second exec which runs your python script also with append msg.payload selected.
You should think about also doing something like setting pid to false when the process is not running and check for this and if it’s not running skip the kill exec.
Johannes
Edit here is a flow that does that:
[{"id":"982fcecc.e486a","type":"inject","z":"5d6b1a8.91496e4","name":"","topic":"","payload":"--help","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["3754046c.b99e7c"]]},{"id":"3754046c.b99e7c","type":"switch","z":"5d6b1a8.91496e4","name":"","property":"pid","propertyType":"flow","rules":[{"t":"false"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":100,"wires":[["365b402.5f7b84"],["c80acf86.678408"]]},{"id":"365b402.5f7b84","type":"exec","z":"5d6b1a8.91496e4","command":"voice2json","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":1410,"y":100,"wires":[[],[],[]]},{"id":"e2a0192.e8d9868","type":"delay","z":"5d6b1a8.91496e4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1240,"y":160,"wires":[["365b402.5f7b84"]]},{"id":"588ea205.651484","type":"change","z":"5d6b1a8.91496e4","name":"","rules":[{"t":"move","p":"secondCommand","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":160,"wires":[["e2a0192.e8d9868"]]},{"id":"c288f914.3279f8","type":"exec","z":"5d6b1a8.91496e4","command":"kill","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":810,"y":160,"wires":[["588ea205.651484"],[],[]]},{"id":"c80acf86.678408","type":"change","z":"5d6b1a8.91496e4","name":"set to pid & move second command","rules":[{"t":"move","p":"payload","pt":"msg","to":"secondCommand","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"pid","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":160,"wires":[["c288f914.3279f8"]]},{"id":"b909e542.18bab8","type":"change","z":"5d6b1a8.91496e4","name":"","rules":[{"t":"set","p":"pid","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":240,"wires":[[]]},{"id":"1fd9e55a.71c003","type":"inject","z":"5d6b1a8.91496e4","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":270,"y":300,"wires":[["b909e542.18bab8"]]},{"id":"ef785fa3.a41398","type":"function","z":"5d6b1a8.91496e4","name":"get pid","func":"if(msg.status.text){\n if(msg.status.text.match(/pid/g)){\n let pid = msg.status.text.split(':');\n msg.payload = pid[1];\n return msg;\n } else {\n msg.payload = false;\n return msg;\n }\n} else {\n msg.payload = false;\n return msg;\n}","outputs":1,"noerr":0,"x":260,"y":240,"wires":[["b909e542.18bab8"]]},{"id":"236b0228.77bc06","type":"status","z":"5d6b1a8.91496e4","name":"","scope":["365b402.5f7b84"],"x":100,"y":240,"wires":[["ef785fa3.a41398"]]}]
of course you have to change the commands to yours.