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

Re: Your mon / s-p-u upload



Hi Team +Adam,


I'm resending this mail because I had no futher comments about this subject.

Can you please tell me if the solution expressed here can be valid to upload the package to s-p-u?

(Anyway, I'n not taking any step until I receive a confirmation)

Thanks again for your time.



On 08/25/2010 08:53 PM, Adam D. Barratt wrote:
> On Sun, 2010-07-18 at 17:33 +0200, Dario Minnucci wrote:
>> On 06/19/2010 11:51 AM, Adam D. Barratt wrote:
>>> I've been reviewing the few remaining packages in s-p-u in
>>> preparation for the upcoming point release and had a couple of
>>> comments / queries on your "mon" upload.
> [...]
>> As suggested, I'm sending this email to debian-release with the
>> debdiff attached.
>>
>> The script seems to be Policy compliant now.
> 
> Sorry for not getting back to you sooner; I seem to have managed to
> misfile your mail.
> 


Same here... comming back from holidays is slow and painfull ;-)


>> +case "$1" in
>> +  start)
>> +       if [ -f $PIDFILE ] ; then
>> +               echo "$NAME daemon is already running." 
>> +       else
>> +               start_deamon
>> +       fi
> 
> The short-circuit case should be removed here; the existence of the
> pidfile does not imply that the daemon is (still) running and your
> start-stop-daemon call in start_daemon() already handles exiting
> successfully if the daemon is in fact running.
> 


I've tried what you suggest here but if I don't check for the existence of the PID file and the
daemon is already running, starting it again fails.

root@host:~# /etc/init.d/mon start ; echo $?
Starting monitor daemon: 1


>>    restart)
> [...]
>> +       if [ -f $PIDFILE ] ; then
>> +               stop_daemon
>> +               sleep 1
>> +               start_deamon
>> +       else
>> +               echo "$NAME daemon is not running."     
>> +               start_deamon
>> +       fi
> 
> Similarly here.  If the daemon is not running, then stop_daemon() will
> successfully fail to stop it with no ill effects.  Admittedly, if the
> pidfile doesn't exist then stop_daemon() is basically a no-op, but not
> simply calling stop_daemon() followed by start_daemon() in all cases
> doesn't really provide any benefit.


Not checking for the PID file here is OK, because stop_daemon() is called before start_daemon().


The attached patch reflecting these changes produces:


--- Tests ---
root@host:~# /etc/init.d/mon stop ; echo $?
Stopping monitor daemon: mon.
0
root@host:~# /etc/init.d/mon stop ; echo $?
Stopping monitor daemon: No process in pidfile `/var/run/mon/mon.pid' found running; none killed.
mon.
0
root@host:~# /etc/init.d/mon start ; echo $?
Starting monitor daemon: mon.
0
root@host:~# /etc/init.d/mon start ; echo $?
mon daemon is already running.
0
root@host:~# /etc/init.d/mon restart ; echo $?
Stopping monitor daemon: mon.
Starting monitor daemon: mon.
0
root@host:~# /etc/init.d/mon restart ; echo $?
Stopping monitor daemon: mon.
Starting monitor daemon: mon.
0
root@host:~# /etc/init.d/mon stop ; echo $?
Stopping monitor daemon: mon.
0
root@host:~# /etc/init.d/mon restart ; echo $?
Stopping monitor daemon: No process in pidfile `/var/run/mon/mon.pid' found running; none killed.
mon.
Starting monitor daemon: mon.
0

--- /Tests ---


Thanks for your time.


-- 
 Dario Minnucci <midget@debian.org>
 Phone: +34 902021030 | Fax: +34 902024417
 Key fingerprint = BAA1 7AAF B21D 6567 D457  D67D A82F BB83 F3D5 7033


diff -u mon-0.99.2/debian/mon.init.d mon-0.99.2/debian/mon.init.d
--- mon-0.99.2/debian/mon.init.d
+++ mon-0.99.2/debian/mon.init.d
@@ -44,16 +44,30 @@
 
 set -e
 
-case "$1" in
-  start)
+
+function start_deamon {
 	echo -n "Starting $DESC: "
-	start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --group $GROUP --exec $DAEMON -- $DAEMON_OPTS
+	start-stop-daemon --start --oknodo --pidfile $PIDFILE --chuid $USER --group $GROUP --exec $DAEMON -- $DAEMON_OPTS
 	echo "$NAME."
-	;;
-  stop)
+}
+function stop_daemon {
 	echo -n "Stopping $DESC: "
-	start-stop-daemon --stop --quiet --pidfile $PIDFILE 
+	start-stop-daemon --stop --oknodo --pidfile $PIDFILE 
 	echo "$NAME."
+}
+
+
+
+case "$1" in
+  start)
+	if [ -f $PIDFILE ] ; then
+		echo "$NAME daemon is already running."	
+	else
+		start_deamon
+	fi
+	;;
+  stop)
+		stop_daemon
 	;;
   #reload)
 	#
@@ -80,11 +94,9 @@
 	|| exit 0
 	;;
   restart)
-    echo -n "Restarting $DESC: "
-	start-stop-daemon --stop --quiet --pidfile $PIDFILE 
-	sleep 1
-	start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --group $GROUP --exec $DAEMON -- $DAEMON_OPTS
-	echo "$NAME."
+		stop_daemon
+		sleep 1
+		start_deamon
 	;;
   *)
 	N=/etc/init.d/$NAME
diff -u mon-0.99.2/debian/changelog mon-0.99.2/debian/changelog
--- mon-0.99.2/debian/changelog
+++ mon-0.99.2/debian/changelog
@@ -1,3 +1,10 @@
+mon (0.99.2-13+lenny1) stable-proposed-updates; urgency=low
+
+  * debian/mon.init.d: Script fixes to return success when daemon 
+    is restarted but is already running. (Closes: #538133)
+
+ -- Dario Minnucci <midget@debian.org>  Sun, 18 Jul 2010 17:09:04 +0200
+
 mon (0.99.2-13) unstable; urgency=low
 
   * debian/control: Conforms with latest Standards Version 3.8.0

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: