I would do something like this...
Get node-red-contrib-queue-gate
.
created test.sh
#!/bin/bash
sleep 1
ls
[{"id":"25e1eef6ce4b9424","type":"inject","z":"f6f2187d.f17ca8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"URL1\", \"URL2\", \"URL3\"]","payloadType":"json","x":370,"y":140,"wires":[["3af88b16ca5d445c","3ae6cfe8c5979ce1"]]},{"id":"3af88b16ca5d445c","type":"split","z":"f6f2187d.f17ca8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":610,"y":140,"wires":[["2bea552356cce723"]]},{"id":"672ad94b70a25389","type":"debug","z":"f6f2187d.f17ca8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":140,"wires":[]},{"id":"2bea552356cce723","type":"q-gate","z":"f6f2187d.f17ca8","name":"","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"100","keepNewest":false,"qToggle":false,"persist":false,"storeName":"memory","x":790,"y":140,"wires":[["a081eb098238d3ef"]]},{"id":"07de6661d34301cf","type":"change","z":"f6f2187d.f17ca8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":240,"wires":[["2bea552356cce723"]]},{"id":"a081eb098238d3ef","type":"exec","z":"f6f2187d.f17ca8","command":"./test.sh","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1020,"y":140,"wires":[["672ad94b70a25389"],["98fddd6acd50f256"],["c5d08422d302e3e6","07de6661d34301cf"]]},{"id":"98fddd6acd50f256","type":"debug","z":"f6f2187d.f17ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":180,"wires":[]},{"id":"c5d08422d302e3e6","type":"debug","z":"f6f2187d.f17ca8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":220,"wires":[]},{"id":"3ae6cfe8c5979ce1","type":"delay","z":"f6f2187d.f17ca8","name":"","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":240,"wires":[["07de6661d34301cf"]]},{"id":"c0ca14cbc9332aed","type":"comment","z":"f6f2187d.f17ca8","name":"https://discourse.nodered.org/t/array-value-transfer/78735","info":"https://discourse.nodered.org/t/array-value-transfer/78735","x":830,"y":60,"wires":[]},{"id":"9b5222b0026d11c0","type":"comment","z":"f6f2187d.f17ca8","name":"test.sh","info":"#!/bin/bash\n\nsleep 1\nls\n","x":750,"y":320,"wires":[]}]
There are probably better ways, but this should do the trick.
Possible enhancements:
- better trigger; the 100ms might not be the best solution depending on speed of system and load. Will not work for constant stream of strings.
- Include error handling; this is missing. If the
test.sh
fails, process will stop.