mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-02 20:46:15 +01:00
56 lines
1.2 KiB
Bash
56 lines
1.2 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
#set -u
|
||
|
set -e -u
|
||
|
|
||
|
PID=$$
|
||
|
echo "pid: $PID"
|
||
|
|
||
|
ROOM=ROOM_$PID
|
||
|
DIR=$(basename $0)_$PID
|
||
|
DICT=dict.xwd
|
||
|
|
||
|
APP=./obj_linux_memdbg/xwords
|
||
|
COMMON_ARGS="--room $ROOM --curses --robot Eric --remote-player --game-dict $DICT --quit-after 2"
|
||
|
|
||
|
mkdir -p $DIR
|
||
|
|
||
|
# Run once to connect each with the relay
|
||
|
for NUM in $(seq 1 2); do
|
||
|
LOG=$DIR/game_${NUM}.log
|
||
|
$APP $COMMON_ARGS --file $DIR/game_${NUM}.xwg > /dev/null 2>$LOG &
|
||
|
PID1=$!
|
||
|
sleep 2
|
||
|
kill $PID1
|
||
|
wait $PID1
|
||
|
done
|
||
|
|
||
|
# run apps until done
|
||
|
NBS=$DIR/nbs
|
||
|
while :; do
|
||
|
for NUM in $(seq 1 2); do
|
||
|
echo "running for $NUM"
|
||
|
LOG=$DIR/game_${NUM}.log
|
||
|
RELAYID=$(./scripts/relayID.sh --short $LOG)
|
||
|
MSG_COUNT=$(../relay/rq -m $RELAYID 2>/dev/null | sed 's,^.*-- ,,')
|
||
|
if [ "$MSG_COUNT" -gt 0 ]; then
|
||
|
echo "calling $APP"
|
||
|
$APP $COMMON_ARGS --file $DIR/game_${NUM}.xwg \
|
||
|
--with-nbs $NBS > /dev/null &
|
||
|
PID1=$!
|
||
|
|
||
|
sleep 1 # let server get ready
|
||
|
echo "calling rq"
|
||
|
../relay/rq -f $RELAYID -b $NBS
|
||
|
|
||
|
sleep 2
|
||
|
kill $PID1 || true
|
||
|
wait $PID1
|
||
|
else
|
||
|
echo "$MSG_COUNT messages for $RELAYID"
|
||
|
fi
|
||
|
done
|
||
|
done
|
||
|
|
||
|
echo "$0 done (pid: $PID)"
|