Author: tmckay
Date: 2012-05-18 14:41:34 +0000 (Fri, 18 May 2012)
New Revision: 5383
Modified:
trunk/cumin/bin/cumin-checkpid
trunk/cumin/etc/sysvinit-cumin
Log:
Tweaks to cumin-checkpid and calls from sysvinit
Modified: trunk/cumin/bin/cumin-checkpid
===================================================================
--- trunk/cumin/bin/cumin-checkpid 2012-05-17 19:55:39 UTC (rev 5382)
+++ trunk/cumin/bin/cumin-checkpid 2012-05-18 14:41:34 UTC (rev 5383)
@@ -41,8 +41,15 @@
parser = OptionParser()
parser.add_option("--exit", dest="exit",
action="store_true", default=False,
- help="Wait for master init to indicate exit")
+ help="Wait for master init to indicate exit")
+ parser.add_option("--timeout", dest="timeout",
default="5", type=int,
+ help="Seconds to wait (default 5) before returning -1" \
+ " when a pid or status file is missing. If both" \
+ " have been read but there is still no status" \
+ " value after timeout seconds, assume success" \
+ "(but a slow master)")
+
(options, args) = parser.parse_args()
# Wait for the pidfile to exist.
@@ -50,31 +57,33 @@
then = datetime.now()
while not os.path.isfile("/var/run/cumin.pid"):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=5):
+ if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
- # Wait for a value
- if not read_val("/var/run/cumin.pid", then, 5):
+ # Wait for a value. This also should happen very
+ # quickly, since the cumin master script write the
+ # pid very early.
+ if not read_val("/var/run/cumin.pid", then, options.timeout):
return -1
- # Now wait for the status file.
+ # Now wait for the status file. It should have
+ # been created before the pid value was written.
# Get the path from a config object for the master.
config = CuminMasterConfig()
p = config.get_init_status_path()
while not os.path.isfile(p):
sleep(0.25)
- if datetime.now() - then > timedelta(seconds=5):
+ if datetime.now() - then > timedelta(seconds=options.timeout):
return -1
# We don't care about the status value here, we
- # just want to see "exit" on the last line of the
- # file
+ # just want to see "exit" on the last line.
if options.exit:
- return read_exit(p, then, 5)
+ return read_exit(p, then, options.timeout)
# Let's read the status. If there is no
# value there, assume success.
- status = read_val(p, then, 10)
+ status = read_val(p, then, options.timeout)
if status is None:
status = 0
return status
Modified: trunk/cumin/etc/sysvinit-cumin
===================================================================
--- trunk/cumin/etc/sysvinit-cumin 2012-05-17 19:55:39 UTC (rev 5382)
+++ trunk/cumin/etc/sysvinit-cumin 2012-05-18 14:41:34 UTC (rev 5383)
@@ -88,7 +88,7 @@
RETVAL=$?
[ $RETVAL = 0 ] && touch $lockfile
if [ $RETVAL = 0 ]; then
- /usr/sbin/cumin-checkpid
+ /usr/sbin/cumin-checkpid --timeout=$DELAY
RETVAL=$?
fi
@@ -96,7 +96,7 @@
if [ $RETVAL -ne 0 ] ; then
# We want to remove the pidfile when the
# cumin master indicates exit
- /usr/sbin/cumin-checkpid --exit
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
if [ $? = 0 ]; then
rm -f $lockfile
rm -f $pidfile
@@ -114,12 +114,12 @@
status $processname -p $pidfile -l $lockfile &> /dev/null
running=$?
- killproc -d $(($DELAY-1)) $servicename SIGTERM
+ killproc $servicename SIGTERM
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
if [ $running -eq 0 ]; then
- /usr/sbin/cumin-checkpid --exit
+ /usr/sbin/cumin-checkpid --exit --timeout=$DELAY
if [ $? -eq 0 ]; then
rm -f $lockfile
rm -f $pidfile