lock files to prevent accidents.

preview will only run if the turn worked out.
cannot accidentally run in the game directory.
This commit is contained in:
Enno Rehling 2014-12-11 12:19:04 +01:00
parent 1a1ffd06b0
commit e5d53769df
2 changed files with 16 additions and 0 deletions

View File

@ -13,7 +13,12 @@ if [ -d $REPORTS ]; then
fi fi
mkdir $REPORTS mkdir $REPORTS
$BIN/backup-eressea $GAME $BIN/backup-eressea $GAME
if [ -d test ]; then
touch test/execute.lock
fi
rm -f execute.lock
$BIN/run-turn $GAME $BIN/run-turn $GAME
touch execute.lock
if [ ! -s $ERESSEA/game-$GAME/orders.$TURN ]; then if [ ! -s $ERESSEA/game-$GAME/orders.$TURN ]; then
echo "server did not create orders for turn $TURN in game $GAME" echo "server did not create orders for turn $TURN in game $GAME"
exit 2 exit 2
@ -31,3 +36,4 @@ $BIN/compress.sh $GAME $TURN
$BIN/sendreports.sh $GAME $BIN/sendreports.sh $GAME
$BIN/backup-eressea $GAME $BIN/backup-eressea $GAME
[ $GAME -lt 4 ] && $BIN/send-summary $GAME [ $GAME -lt 4 ] && $BIN/send-summary $GAME
rm -f test/execute.lock

View File

@ -182,6 +182,16 @@ function run_turn(rules)
return result return result
end end
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
if file_exists('execute.lock') then
eressea.log.error("Lockfile exists, aborting.")
assert(false)
end
local path = 'scripts' local path = 'scripts'
if config.install then if config.install then
path = config.install .. '/' .. path path = config.install .. '/' .. path