Hi,
I found web2py.fedora.sh script have couple of problems in
start() and stop(). So here's explanation and my solutions.

If these fixes looks good, I can write a clean fix, test and send you
a patch,
could be tested only on RHEL6.

--------
(A) when calling daemon() shell-function, it is called as background.
daemon() executes web2py.py as forground process inside of the
function,
and doesn't return until web2py.py terminates.
So it shows "[ OK ]" (of startup) at termination!

<current call flow>
web2py.fedra.sh
    -> daemon &
      -> web2py.py

As far as I looked into the /etc/init.d/functions, the daemon()
function
expects the service (web2py.py in this case) to daemonize itself.
So my solution would be:

<new call flow>
web2py.fedra.sh
    ->  daemon
      -> web2py-daemon.sh  # new script to invoke web2py.py in
background
        -> web2py.py  &

Or add something like --daemon option to web2py.py.
Or, perhaps little bit tricky sub-shell like 'bash -c
"( web2py.py& )"' could be used...?

--------
(B) when stop()ing the web2py service, it sends TERM signal, but not
wait for
it's actual termination.

Actually, there's killproc() shell function (counter part of daemon()
function)

  Usage: killproc [-p pidfile] [ -d delay] {program} [-signal]"

diff -r 3f8ce51b069e start-stop-web2py
--- a/start-stop-web2py Thu Aug 25 09:40:24 2011 +0900
+++ b/start-stop-web2py Thu Aug 25 10:26:11 2011 +0900
@@ -66,14 +66,7 @@

 stop() {
     echo -n $"Shutting down $DESC ($NAME): "
-    if [ -r "$PIDFILE" ]; then
-        pid=`cat $PIDFILE`
-        kill -TERM $pid
-        RETVAL=$?
-    else
-        RETVAL=1
-    fi
-    [ $RETVAL -eq 0 ] && success || failure
+    killproc -p "$PIDFILE" -d 3 "$NAME"
     echo
     if [ $RETVAL -eq 0 ]; then
         is_production && rm -f /var/lock/subsys/$NAME

--
R.Kato

Reply via email to