commit c8b1c0728990d5cd0e36ce3a3f473ce2382f12e4 parent 5076dd7380dbf45941d17872a0b45dac274455aa Author: finwo <finwo@pm.me> Date: Wed, 22 Feb 2017 20:08:13 +0100 Crossroads now just a bonus, not required Diffstat:
| M | run.sh | | | 26 | +++++++++++++++++--------- |
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/run.sh b/run.sh @@ -3,12 +3,20 @@ XRARGS="-x -s http:0.0.0.0:$PORT" rm fifo.* 2>/dev/null -for i in {0..9} ; do - XRARGS="$XRARGS -b 127.0.0.1:800$i" - echo Starting handler: 800$i - { while true ; do FIFO=$(hexdump -n 16 -v -e '/1 "%02X"' -e '/16 "\n"' /dev/urandom) ; mkfifo fifo.$FIFO ; nc -l 800$i < fifo.$FIFO | php init.php > fifo.$FIFO ; rm fifo.$FIFO ; done } & -done; - -echo Starting load-balancer on $PORT -echo xr $XRARGS -xr $XRARGS +test -v "$PORT" || PORT=5000 + +# Use a load-balancer if possible +command -v xr >/dev/null 2>/dev/null && { + for i in {0..9} ; do + XRARGS="$XRARGS -b 127.0.0.1:800$i" + echo Starting handler on 800$i + { while true ; do FIFO=$(hexdump -n 16 -v -e '/1 "%02X"' -e '/16 "\n"' /dev/urandom) ; mkfifo fifo.$FIFO ; nc -l -p 800$i < fifo.$FIFO | php init.php > fifo.$FIFO ; rm fifo.$FIFO ; done } & + done; + echo Starting load-balancer on $PORT + echo xr $XRARGS + xr $XRARGS +} || { + echo Starting on $PORT + while true ; do FIFO=$(hexdump -n 16 -v -e '/1 "%02X"' -e '/16 "\n"' /dev/urandom) ; mkfifo fifo.$FIFO ; nc -l -p $PORT < fifo.$FIFO | php init.php > fifo.$FIFO ; rm fifo.$FIFO ; done +} +