cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/init.d luci
Date: 5 Feb 2008 18:31:31 -0000	[thread overview]
Message-ID: <20080205183131.24183.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2008-02-05 18:31:31

Modified files:
	luci/init.d    : luci 

Log message:
	- stop-after-stop should return success
	- cleanup

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/init.d/luci.diff?cvsroot=cluster&r1=1.19&r2=1.20

--- conga/luci/init.d/luci	2008/01/02 20:52:23	1.19
+++ conga/luci/init.d/luci	2008/02/05 18:31:30	1.20
@@ -121,11 +121,34 @@
 stop()
 {
 	stop_stunnel
+	max_wait=5
+	cur_wait=0
+	while [ $cur_wait -lt $max_wait ]; do
+		sleep 1
+		cur_wait=`expr $cur_wait + 1`
+		stunnel_running
+		if [ $? -eq 0 ]; then
+			break
+		fi
+	done
+
 	if [ $? -ne 0 ]; then
 		errmsg='Failed to stop stunnel'
 		return 1
 	fi
+
 	stop_luci
+	max_wait=10
+	cur_wait=0
+	while [ $cur_wait -lt $max_wait ]; do
+		sleep 1
+		cur_wait=`expr $cur_wait + 1`
+		luci_running
+		if [ $? -eq 0 ]; then
+			break
+		fi
+	done
+
 	if [ $? -ne 0 ]; then
 		errmsg='Failed to stop luci'
 		return 1
@@ -145,29 +168,69 @@
 	fi
 
 	sh $LUCID >&/dev/null &
-	sleep 4
+
+	cur_wait=0
+	max_wait=10
+	luci_running
+	ret=$?
+	while [ $ret -ne 1 ] && [ $cur_wait -lt $max_wait ]; do
+		sleep 1
+		cur_wait=`expr $cur_wait + 1`
+		luci_running
+		ret=$?
+	done
+
+	if [ $ret -ne 1 ]; then
+		errmsg='An error occurred while starting luci'
+		stop_luci
+		return 1
+	fi
 
 	sed -e s,\\\(^accept.*=\ \\\)\\\(.*\\\),\\\1$LUCI_HTTPS_PORT, $STUNNEL_CONF | $STUNNEL_D -fd 0
 	if [ $? -ne 0 ]; then
 		errmsg='An error occurred while starting stunnel'
-		stop_luci
+		stop_luci >& /dev/null
+		return 1
+	fi
+
+	max_wait=5
+	cur_wait=0
+	stunnel_running
+	ret=$?
+	while [ $ret -ne 2 ] && [ $cur_wait -lt $max_wait ]; do
+		sleep 1
+		cur_wait=`expr $cur_wait + 1`
+		stunnel_running
+		ret=$?
+	done
+
+	if [ $ret -ne 2 ]; then
+		errmsg='An error occurred while starting stunnel'
+		stop_luci >& /dev/null
+		stop_stunnel >& /dev/null 
 		return 1
 	fi
+
 	return 0
 }
 
 luci_running()
 {
 	LUCI_UP=1
-	pgrep -u "$LUCI_USER" python >&/dev/null
-	if [ $? -ne 0 ]; then
+
+	test -f "$PIDFILE"
+	LUCI_PID_EXISTS=$?
+	if [ "$LUCI_PID_EXISTS" -eq 0 ]; then
+		pgrep -u "$LUCI_USER" python >&/dev/null
+		if [ $? -ne 0 ]; then
+			LUCI_UP=0
+			# remove stale pidfile
+			rm -f "$PIDFILE" >& /dev/null
+		fi
+	else
 		LUCI_UP=0
 	fi
 
-	if [ -f "$PIDFILE" ] && [ $LUCI_UP -eq 0 ]; then
-		# stale pidfile
-		rm -f "$PIDFILE" >& /dev/null
-	fi
 	return $LUCI_UP
 }
 
@@ -252,15 +315,15 @@
 			echo_success
 			cat "$PIDFILE" > "$GLOB_PIDFILE"
 			touch "$GLOB_LOCKFILE"
-			/usr/bin/logger -t "$ID" "Luci startup succeeded"
-			/usr/bin/logger -t "$ID" "Listening on port $LUCI_HTTPS_PORT; accessible via URL $LUCI_URL"
+			/usr/bin/logger -t "$ID" -- "Luci startup succeeded"
+			/usr/bin/logger -t "$ID" -- "Listening on port $LUCI_HTTPS_PORT; accessible via URL $LUCI_URL"
 			echo; echo
 			echo "Point your web browser to $LUCI_URL to access luci"
 			echo
 			exit 0
 		else
 			echo_failure
-			/usr/bin/logger -t "$ID" "Luci startup failed $errmsg"
+			/usr/bin/logger -t "$ID" -- "Luci startup failed $errmsg"
 			echo
 			exit 1
 		fi
@@ -269,7 +332,7 @@
 	restart)
 		$0 stop
 		rtrn=$?
-		if [ $rtrn -eq 0 ] || [ $rtrn -eq 7 ]; then
+		if [ $rtrn -eq 0 ];  then
 			$0 start
 			rtrn=$?
 		fi
@@ -311,7 +374,7 @@
 				rtrn=1
 			fi
 		elif [ $rtrn -eq 0 ]; then
-			rtrn=7
+			rtrn=0
 		else
 			rtrn=1
 		fi
@@ -324,6 +387,10 @@
 		echo
 	;;
 
+	try-restart)
+		rtrn=3
+	;;
+
 	reload)
 		rtrn=3
 	;;



             reply	other threads:[~2008-02-05 18:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 18:31 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-02-04 23:36 [Cluster-devel] conga/luci/init.d luci rmccabe
2008-02-05 18:41 rmccabe
2007-06-05 16:03 rmccabe
2007-05-22  1:39 rmccabe
2007-03-15 16:52 rmccabe
2007-02-20 17:56 rmccabe
2006-11-02  0:23 kupcevic
2006-10-03 18:23 kupcevic
2006-09-26  0:22 kupcevic
2006-07-17 20:56 kupcevic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080205183131.24183.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).