mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
save logs, and exit loop when log dir disappears to make killing it easier.
This commit is contained in:
parent
350220645a
commit
35a924cadd
1 changed files with 16 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue