restart
dirt31/bin/restart · 1.4 KB
From the archive dirt31.tar.gz
Download the archive « Back to the archive contents
#!/bin/sh
#
# Restart the mud-server if it has crashed, kill it if it thinks it uses
# too much CPU-time. (this used to be a problem but it should be fixed now.
# but why not just leave the kill-code in here anyway..)
#
# Restarts are logged to data/restart.log and kill-mud's are logged to
# data/kill.log
cd /home/gyda/c/gjermund/src/dirt31/bin
trap '' 1
count=0
LIMIT=2
( while : ; do
mudproc=`ps ux | grep -v grep | egrep '^${USER}.+ aberd'`
if [ ! "$mudproc" ]; then
echo "Restart at `date`" >> ../data/restart.log
/bin/nice -19 aberd -k > /dev/null 2>&1
else
set $mudproc
if [ "$3" -gt 30 ]; then
count=`expr "$count" + 1`
test "$count" -ge $LIMIT && {
count=0
echo "Kill at `date`: $*" \
>> ../data/kill.log
kill $2
sleep 10
/bin/nice -19 aberd -k > /dev/null 2>&1
}
else
count=0
fi
fi
sleep 180
done \
)&