Fix domr's file lock

And add more information for domr's file lock
This commit is contained in:
Sheng Yang 2012-01-10 14:22:29 -08:00
parent 495e9ad113
commit f98191be5c
3 changed files with 26 additions and 7 deletions

View File

@ -24,7 +24,8 @@ getLockFile() {
return
fi
touch $__LOCKFILE
psline=`ps u $$`
echo $psline > $__LOCKFILE
for i in `seq 1 $(($__TIMEOUT * 10))`
do
@ -43,8 +44,11 @@ getLockFile() {
if [ $__locked -ne 1 ]
then
logger -t cloud "fail to acquire the lock $1 for process $0 pid $$ after $__TIMEOUT seconds time out!"
cmd=`cat $currlock`
logger -t cloud "waiting for command: $cmd"
psline=`ps u $$`
logger -t cloud "Failed job detail: $psline"
rm $__LOCKFILE
fi
echo $__locked
}

View File

@ -260,7 +260,7 @@ grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
if [ $? -eq 0 ]
then
is_redundant=1
sudo /root/checkrouter.sh|grep "Status: MASTER" > /dev/null 2>&1
sudo /root/checkrouter.sh --no-lock|grep "Status: MASTER" > /dev/null 2>&1
if [ $? -eq 0 ]
then
is_master=1

View File

@ -2,11 +2,23 @@
source /root/func.sh
lock="biglock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
nolock=0
if [ $# -eq 1 ]
then
exit 1
if [ $1 == "--no-lock" ]
then
nolock=1
fi
fi
if [ $nolock -eq 0 ]
then
lock="biglock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
then
exit 1
fi
fi
bumped="Bumped: NO"
@ -21,4 +33,7 @@ then
echo "$stat&$bumped"
fi
unlock_exit $? $lock $locked
if [ $nolock -eq 0 ]
then
unlock_exit $? $lock $locked
fi