Revert "bug 11266: Add lockfile for scripts in system vm"

This last minute check in is lack of test, revert it for 2.2.10, push it to
2.2.11.

This reverts commit a6d28f9e988a5a1044307f6b75f95c6835f940b9.
This commit is contained in:
Sheng Yang 2011-08-26 14:05:43 -07:00
parent 1953869634
commit 32bb0cebef
2 changed files with 3 additions and 60 deletions

View File

@ -1,44 +0,0 @@
#!/bin/bash
# getLockFile() parameters
# $1 lock filename
# $2 timeout seconds
getLockFile() {
__locked=0
__LOCKFILE="/tmp/$1.lock"
if [ $2 ]
then
__TIMEOUT=$2
else
__TIMEOUT=10
fi
for i in `seq 1 $__TIMEOUT`
do
if [ ! -e $__LOCKFILE ]
then
touch $__LOCKFILE
__locked=1
break
fi
sleep 1
logger -t cloud "sleep 1 second wait for the lock file " $__LOCKFILE
done
if [ $__locked -ne 1 ]
then
logger -t cloud "fail to acquire the lock file $__LOCKFILE after $__TIMEOUT seconds time out!"
fi
echo $__locked
}
# releaseLockFile() parameters
# $1 lock filename
# $2 locked(1) or not(0)
releaseLockFile() {
__LOCKFILE="/tmp/$1.lock"
__locked=$2
if [ "$__locked" == "1" ]
then
rm $__LOCKFILE
fi
}

View File

@ -18,18 +18,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
name="reconfigLB"
source func.sh
locked=$(getLockFile $name)
if [ "$locked" != "1" ]
then
logger -t cloud "Fail to get the lock for " $name
exit 1
fi
ret=0
# save previous state
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.old
mv /var/run/haproxy.pid /var/run/haproxy.pid.old
@ -41,7 +32,7 @@ ret=0
echo "New haproxy instance successfully loaded, stopping previous one."
kill -KILL $(cat /var/run/haproxy.pid.old)
rm -f /var/run/haproxy.pid.old
ret=0
exit 0
else
echo "New instance failed to start, resuming previous one."
kill -TTIN $(cat /var/run/haproxy.pid.old)
@ -49,9 +40,5 @@ ret=0
mv /var/run/haproxy.pid.old /var/run/haproxy.pid
mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.new
mv /etc/haproxy/haproxy.cfg.old /etc/haproxy/haproxy.cfg
ret=1
exit 1
fi
releaseLockFile $name $locked
exit $ret