[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

PATCH: fix start/stop problems with /etc/init.d/jetty



/etc/init.d/jetty 1.3 still has some problems with start/stop
and  /var/run/jetty.pid.

Is this the right spot to post patches?



-- 
Øyvind Harboe
http://www.zylin.com
Index: changelog
===================================================================
RCS file: /cvsroot/pkg-java/jetty/debian/changelog,v
retrieving revision 1.5
diff -u -r1.5 changelog
--- changelog	30 Aug 2005 12:32:22 -0000	1.5
+++ changelog	31 Aug 2005 11:49:30 -0000
@@ -1,3 +1,16 @@
+
+  * Fixed rc script /etc/init.d/jetty. "stop" could leave dangling
+  /var/run/jetty.pid. Fixed this by adding "--oknodo" to 
+  "start-stop-daemon --stop" command
+  * Removed trailing "/" from LOGDIR which caused
+  /var/log/out.log not to be created.
+  * /etc/init.d/jetty start will now deal more gracefully with a 
+  dangling /var/run/jetty.pid. A dangling jetty.pid is detected
+  and ignored.
+  
+ -- Oyvind Harboe <oyvind.harboe@zylin.com> 
+  
+  	
 jetty (5.1.5rc1-3) unstable; urgency=low
 
   * Removed -v from ant opts during build.
Index: jetty.init
===================================================================
RCS file: /cvsroot/pkg-java/jetty/debian/jetty.init,v
retrieving revision 1.3
diff -u -r1.3 jetty.init
--- jetty.init	30 Aug 2005 12:32:22 -0000	1.3
+++ jetty.init	31 Aug 2005 11:49:30 -0000
@@ -68,7 +68,7 @@
                                                                                 
 # Define other required variables
 PIDFILE="/var/run/$NAME.pid"
-LOGDIR="/var/log/jetty/"
+LOGDIR="/var/log/jetty"
 WEBAPPDIR="$JETTY_HOME/webapps"
 
 ##################################################
@@ -89,23 +89,24 @@
 ##################################################
 case "$1" in
   start)
-        echo -n "Starting $DESC: "
+	if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
+	                --user "$JETTY_USER" --startas "$JAVA" > /dev/null; then 
+
 
-        if [ -f $PIDFILE ]
-        then
-            echo "already running."
-            exit 1
-        fi
 
-	# Look for rotatelogs/rotatelogs2
-	if [ -x /usr/sbin/rotatelogs ]; then
+	    # Look for rotatelogs/rotatelogs2
+	    if [ -x /usr/sbin/rotatelogs ]; then
 		ROTATELOGS=/usr/sbin/rotatelogs
-	else
+	    else
 		ROTATELOGS=/usr/sbin/rotatelogs2
-	fi
+	    fi
 
-	if start-stop-daemon --quiet --test --start --pidfile "$PIDFILE" \
-	                --user "$JETTY_USER" --startas "$JAVA" > /dev/null; then 
+	    if [ -f $PIDFILE ]
+		then
+			echo "$PIDFILE exists, but jetty was not running. Ignoring $PIDFILE"
+	    fi
+
+	    echo -n "Starting $DESC: "
 		su -p -s /bin/sh "$JETTY_USER" \
 			-c "$ROTATELOGS \"$LOGDIR/out.log\" 86400" \
 			< "$LOGDIR/out.log" &
@@ -114,8 +115,9 @@
 			    echo \$!"  > "$PIDFILE"
                 echo "$NAME."
 	else
-                echo "(already running)."
-        fi
+        echo "(already running)."
+		exit 1
+    fi
         ;;
 
   stop)
@@ -132,14 +134,14 @@
 		start-stop-daemon --quiet --stop \
 			--pidfile "$PIDFILE" --user "$JETTY_USER" \
 			--startas "$JAVA" > /dev/null
-                while ! start-stop-daemon --quiet --test --stop \
+                while ! start-stop-daemon --quiet --test --start \
 			--pidfile "$PIDFILE" --user "$JETTY_USER" \
 			--startas "$JAVA" > /dev/null; do 
                         sleep 1
                         echo -n "."
                         JETTY_SHUTDOWN=`expr $JETTY_SHUTDOWN - 1` || true
                         if [ $JETTY_SHUTDOWN -ge 0 ]; then
-				start-stop-daemon --quiet --stop \
+				start-stop-daemon --oknodo --quiet --stop \
 					--pidfile "$PIDFILE" --user "$JETTY_USER" \
 					--startas "$JAVA"
 			else
@@ -184,5 +186,3 @@
 esac
 
 exit 0
-
-

Reply to: