save logs, and exit loop when log dir disappears to make killing it easier.

This commit is contained in:
eehouse 2010-02-08 13:45:48 +00:00
parent 350220645a
commit 35a924cadd

View file

@ -5,9 +5,14 @@ ROOM_ADD=""
NGAMES=10
PORT=10999
DBUG=0
HOW_LONG=1000
HOW_LONG=360
DICT=dict.xwd
RUN_NAME=$(basename $0)_$$
LOG_DIR=/tmp/${RUN_NAME}_LOG
mkdir -p ${LOG_DIR}
usage() {
[ -n "$1" ] && echo "$1" >&2
echo "usage: $0 \\" >&2
@ -27,16 +32,18 @@ do_one() {
EXE=$1
INDEX=$2
while :; do
while [ -d ${LOG_DIR} ]; do
ROOM="playme ${INDEX}$ROOM_ADD"
LOG_FILE="${LOG_DIR}/${ROOM}.log"
#COMMAND="$EXE -u -0 -C \"$ROOM\" -a $HOSTNAME -r Relay -d $DICT -p $PORT"
# it's a server if INDEX is odd
if [ 0 -eq $((INDEX%2)) ]; then
if [ 0 -ne $((INDEX%2)) ]; then
SERVER=" -s -N "
fi
#echo $COMMAND
$EXE -u -0 -C "$ROOM" -a $HOSTNAME -r Relay -d $DICT -p $PORT $SERVER >/dev/null 2>&1 &
$EXE -u -0 -C "$ROOM" -a $HOSTNAME -r Relay -d $DICT -p $PORT $SERVER \
>/dev/null 2>>${LOG_FILE} &
PID=$!
echo "launched $ROOM ($PID)"
@ -44,7 +51,11 @@ do_one() {
while [ -d /proc/$PID ]; do
sleep 10
if [ $(date +%s) -ge $END_TIME ]; then
if [ ! -d ${LOG_DIR} ]; then
break
elif [ ! -d /proc/$PID ]; then
break
elif [ $(date +%s) -ge $END_TIME ]; then
echo "timing out $ROOM ($PID)"
break
fi