mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
Separate app from params. No change in behavior (though restart of
existing games is now broken), but this sets up testing mid-game upgrade.
This commit is contained in:
parent
ba5ff6cb5d
commit
c8b868c243
1 changed files with 33 additions and 37 deletions
|
@ -59,7 +59,8 @@ mkdir -p $DEADDIR
|
||||||
USE_GTK=${USE_GTK:-FALSE}
|
USE_GTK=${USE_GTK:-FALSE}
|
||||||
|
|
||||||
declare -A PIDS
|
declare -A PIDS
|
||||||
declare -A CMDS
|
declare -A APPS
|
||||||
|
declare -A ARGS
|
||||||
declare -A ROOMS
|
declare -A ROOMS
|
||||||
declare -A FILES
|
declare -A FILES
|
||||||
declare -A LOGS
|
declare -A LOGS
|
||||||
|
@ -141,22 +142,24 @@ build_cmds() {
|
||||||
FILE="${LOGDIR}/GAME_${GAME}_${DEV}.xwg"
|
FILE="${LOGDIR}/GAME_${GAME}_${DEV}.xwg"
|
||||||
LOG=${LOGDIR}/${GAME}_${DEV}_LOG.txt
|
LOG=${LOGDIR}/${GAME}_${DEV}_LOG.txt
|
||||||
touch $LOG # so greps won't show errors
|
touch $LOG # so greps won't show errors
|
||||||
CMD="./obj_linux_memdbg/xwords --room $ROOM"
|
APPS[$COUNTER]=./obj_linux_memdbg/xwords
|
||||||
CMD="$CMD --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) "
|
PARAMS="--room $ROOM"
|
||||||
CMD="$CMD $OTHERS --game-dict $DICT --port $PORT --host $HOST "
|
PARAMS="$PARAMS --robot ${NAMES[$DEV]} --robot-iq $((1 + (RANDOM%100))) "
|
||||||
CMD="$CMD --file $FILE --slow-robot 1:3 --skip-confirm"
|
PARAMS="$PARAMS $OTHERS --game-dict $DICT --port $PORT --host $HOST "
|
||||||
CMD="$CMD --drop-nth-packet $DROP_N $PLAT_PARMS"
|
PARAMS="$PARAMS --file $FILE --slow-robot 1:3 --skip-confirm"
|
||||||
[ -n "$SEED" ] && CMD="$CMD --seed $RANDOM"
|
PARAMS="$PARAMS --drop-nth-packet $DROP_N $PLAT_PARMS"
|
||||||
CMD="$CMD --board-size ${BOARD_SIZES[$((RANDOM%${#BOARD_SIZES[*]}))]}"
|
[ -n "$SEED" ] && PARAMS="$PARAMS --seed $RANDOM"
|
||||||
CMD="$CMD $PUBLIC"
|
PARAMS="$PARAMS --board-size ${BOARD_SIZES[$((RANDOM%${#BOARD_SIZES[*]}))]}"
|
||||||
CMDS[$COUNTER]=$CMD
|
PARAMS="$PARAMS $PUBLIC"
|
||||||
|
ARGS[$COUNTER]=$PARAMS
|
||||||
ROOMS[$COUNTER]=$ROOM
|
ROOMS[$COUNTER]=$ROOM
|
||||||
FILES[$COUNTER]=$FILE
|
FILES[$COUNTER]=$FILE
|
||||||
LOGS[$COUNTER]=$LOG
|
LOGS[$COUNTER]=$LOG
|
||||||
PIDS[$COUNTER]=0
|
PIDS[$COUNTER]=0
|
||||||
COUNTER=$((COUNTER+1))
|
|
||||||
|
|
||||||
echo "${CMD}" > $LOG
|
echo "${APPS[$COUNTER]} ${PARAMS}" > $LOG
|
||||||
|
|
||||||
|
COUNTER=$((COUNTER+1))
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
echo "finished creating $COUNTER commands"
|
echo "finished creating $COUNTER commands"
|
||||||
|
@ -165,9 +168,11 @@ build_cmds() {
|
||||||
read_resume_cmds() {
|
read_resume_cmds() {
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
for LOG in $(ls $LOGDIR/*.txt); do
|
for LOG in $(ls $LOGDIR/*.txt); do
|
||||||
|
echo "need to parse cmd and deal with changes"
|
||||||
|
exit 1
|
||||||
CMD=$(head -n 1 $LOG)
|
CMD=$(head -n 1 $LOG)
|
||||||
|
|
||||||
CMDS[$COUNTER]=$CMD
|
ARGS[$COUNTER]=$CMD
|
||||||
LOGS[$COUNTER]=$LOG
|
LOGS[$COUNTER]=$LOG
|
||||||
PIDS[$COUNTER]=0
|
PIDS[$COUNTER]=0
|
||||||
|
|
||||||
|
@ -192,8 +197,9 @@ read_resume_cmds() {
|
||||||
|
|
||||||
launch() {
|
launch() {
|
||||||
LOG=${LOGS[$1]}
|
LOG=${LOGS[$1]}
|
||||||
CMD="${CMDS[$1]}"
|
APP="${APPS[$1]}"
|
||||||
exec $CMD >/dev/null 2>>$LOG
|
PARAMS="${ARGS[$1]}"
|
||||||
|
exec $APP $PARAMS >/dev/null 2>>$LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
# launch_via_rq() {
|
# launch_via_rq() {
|
||||||
|
@ -217,7 +223,7 @@ close_device() {
|
||||||
[ ${ROOM_PIDS[$ROOM]} -eq $PID ] && ROOM_PIDS[$ROOM]=0
|
[ ${ROOM_PIDS[$ROOM]} -eq $PID ] && ROOM_PIDS[$ROOM]=0
|
||||||
fi
|
fi
|
||||||
unset PIDS[$ID]
|
unset PIDS[$ID]
|
||||||
unset CMDS[$ID]
|
unset ARGS[$ID]
|
||||||
echo "closing game: $REASON" >> ${LOGS[$ID]}
|
echo "closing game: $REASON" >> ${LOGS[$ID]}
|
||||||
if [ -n "$MVTO" ]; then
|
if [ -n "$MVTO" ]; then
|
||||||
[ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO
|
[ -f ${FILES[$ID]} ] && mv ${FILES[$ID]} $MVTO
|
||||||
|
@ -229,6 +235,7 @@ close_device() {
|
||||||
unset FILES[$ID]
|
unset FILES[$ID]
|
||||||
unset LOGS[$ID]
|
unset LOGS[$ID]
|
||||||
unset ROOMS[$ID]
|
unset ROOMS[$ID]
|
||||||
|
unset APPS[$ID]
|
||||||
}
|
}
|
||||||
|
|
||||||
OBITS=""
|
OBITS=""
|
||||||
|
@ -309,12 +316,12 @@ check_game() {
|
||||||
|
|
||||||
increment_drop() {
|
increment_drop() {
|
||||||
KEY=$1
|
KEY=$1
|
||||||
CMD=${CMDS[$KEY]}
|
CMD=${ARGS[$KEY]}
|
||||||
if [ "$CMD" != "${CMD/drop-nth-packet//}" ]; then
|
if [ "$CMD" != "${CMD/drop-nth-packet//}" ]; then
|
||||||
DROP_N=$(echo $CMD | sed 's,^.*drop-nth-packet \(-*[0-9]*\) .*$,\1,')
|
DROP_N=$(echo $CMD | sed 's,^.*drop-nth-packet \(-*[0-9]*\) .*$,\1,')
|
||||||
if [ $DROP_N -gt 0 ]; then
|
if [ $DROP_N -gt 0 ]; then
|
||||||
NEXT_N=$((DROP_N+1))
|
NEXT_N=$((DROP_N+1))
|
||||||
CMDS[$KEY]=$(echo $CMD | sed "s,^\(.*drop-nth-packet \)$DROP_N\(.*\)$,\1$NEXT_N\2,")
|
ARGS[$KEY]=$(echo $CMD | sed "s,^\(.*drop-nth-packet \)$DROP_N\(.*\)$,\1$NEXT_N\2,")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -322,12 +329,13 @@ increment_drop() {
|
||||||
run_cmds() {
|
run_cmds() {
|
||||||
ENDTIME=$(($(date +%s) + TIMEOUT))
|
ENDTIME=$(($(date +%s) + TIMEOUT))
|
||||||
while :; do
|
while :; do
|
||||||
COUNT=${#CMDS[*]}
|
COUNT=${#ARGS[*]}
|
||||||
|
echo "COUNT: $COUNT"
|
||||||
[ 0 -ge $COUNT ] && break
|
[ 0 -ge $COUNT ] && break
|
||||||
NOW=$(date '+%s')
|
NOW=$(date '+%s')
|
||||||
[ $NOW -ge $ENDTIME ] && break
|
[ $NOW -ge $ENDTIME ] && break
|
||||||
INDX=$(($RANDOM%COUNT))
|
INDX=$(($RANDOM%COUNT))
|
||||||
KEYS=( ${!CMDS[*]} )
|
KEYS=( ${!ARGS[*]} )
|
||||||
KEY=${KEYS[$INDX]}
|
KEY=${KEYS[$INDX]}
|
||||||
ROOM=${ROOMS[$KEY]}
|
ROOM=${ROOMS[$KEY]}
|
||||||
if [ 0 -eq ${PIDS[$KEY]} ]; then
|
if [ 0 -eq ${PIDS[$KEY]} ]; then
|
||||||
|
@ -357,27 +365,15 @@ run_cmds() {
|
||||||
if [ $COUNT -gt 0 ]; then
|
if [ $COUNT -gt 0 ]; then
|
||||||
mkdir -p ${LOGDIR}/not_done
|
mkdir -p ${LOGDIR}/not_done
|
||||||
echo "processing unfinished games...."
|
echo "processing unfinished games...."
|
||||||
for KEY in ${!CMDS[*]}; do
|
for KEY in ${!ARGS[*]}; do
|
||||||
close_device $KEY ${LOGDIR}/not_done "unfinished game"
|
close_device $KEY ${LOGDIR}/not_done "unfinished game"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# add_pipe() {
|
|
||||||
# KEY=$1
|
|
||||||
# CMD=${CMDS[$KEY]}
|
|
||||||
# LOG=${LOGS[$KEY]}
|
|
||||||
# PIPE=${LOG/LOG.txt/pipe}
|
|
||||||
# PIPES[$KEY]=$PIPE
|
|
||||||
# echo "mkfifo $PIPE"
|
|
||||||
# mkfifo $PIPE
|
|
||||||
# CMDS[$KEY]="$CMD --with-pipe $PIPE"
|
|
||||||
# echo ${CMDS[$KEY]}
|
|
||||||
# }
|
|
||||||
|
|
||||||
run_via_rq() {
|
run_via_rq() {
|
||||||
# launch then kill all games to give chance to hook up
|
# launch then kill all games to give chance to hook up
|
||||||
for KEY in ${!CMDS[*]}; do
|
for KEY in ${!ARGS[*]}; do
|
||||||
echo "launching $KEY"
|
echo "launching $KEY"
|
||||||
launch $KEY &
|
launch $KEY &
|
||||||
PID=$!
|
PID=$!
|
||||||
|
@ -390,13 +386,13 @@ run_via_rq() {
|
||||||
echo "now running via rq"
|
echo "now running via rq"
|
||||||
# then run them
|
# then run them
|
||||||
while :; do
|
while :; do
|
||||||
COUNT=${#CMDS[*]}
|
COUNT=${#ARGS[*]}
|
||||||
[ 0 -ge $COUNT ] && break
|
[ 0 -ge $COUNT ] && break
|
||||||
|
|
||||||
INDX=$(($RANDOM%COUNT))
|
INDX=$(($RANDOM%COUNT))
|
||||||
KEYS=( ${!CMDS[*]} )
|
KEYS=( ${!ARGS[*]} )
|
||||||
KEY=${KEYS[$INDX]}
|
KEY=${KEYS[$INDX]}
|
||||||
CMD=${CMDS[$KEY]}
|
CMD=${ARGS[$KEY]}
|
||||||
|
|
||||||
RELAYID=$(./scripts/relayID.sh --short ${LOGS[$KEY]})
|
RELAYID=$(./scripts/relayID.sh --short ${LOGS[$KEY]})
|
||||||
MSG_COUNT=$(../relay/rq -a $HOST -m $RELAYID 2>/dev/null | sed 's,^.*-- ,,')
|
MSG_COUNT=$(../relay/rq -a $HOST -m $RELAYID 2>/dev/null | sed 's,^.*-- ,,')
|
||||||
|
|
Loading…
Add table
Reference in a new issue