Guillaume Cottenceau wrote on Thu, Jun 13, 2002 at 09:26:52PM +0200 :
> > 
> > Hmm, maybe.  But there's something really strange - when I run service
> > webmin start, I do not get any error message.  Only during bootup I get
> > this error message?!  There's also no error message in some log file in
> > /var/log.
> > Strange.
> Agreed.

I too experienced very strange issues when writing an init script to
start Jakarta Tomcat with Java.  I've quoted the final init script at
the end of this email.

The issue I had was it died when I did a "service xxxname restart".  It
*seemed* to start ok, but as soon as you pointed a browser at it, it
died.  If I did stop, then a start, everything worked fine.  Restart was
the only thing that didn't work.  I suspect it has to do with spawning a
shell that spawns a shell.  Look at the script:

start() {
        gprintf "Starting up Apache daemon: "
        daemon /usr/local/apache/bin/apachectl start
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/httpd
        echo
        gprintf "Cleaning up stray java processes"
        sleep 1
        killall java
        sleep 1
        killall -9 java
        echo
        gprintf "Starting up Jakarta Tomcat daemon: "
        daemon $TOMCAT/bin/startup.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jakarta
        echo
        gprintf "Starting up Jakarta Tomcat (external) daemon: "
        export CATALINA_BASE=$TOMCAT-external
        daemon $TOMCAT/bin/startup.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/jakarta-external
}
stop() {
        gprintf "Shutting down Jakarta Tomcat daemon: "
        $TOMCAT/bin/shutdown.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jakarta
        echo
        gprintf "Shutting down Jakarta Tomcat (external) daemon: "
        export CATALINA_BASE=$TOMCAT-external
        $TOMCAT/bin/shutdown.sh
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jakarta-external
        echo
}
restart() {
        echo
        echo "Sorry, java has weird issues when the restart is invoked"
        echo "from the init script.  Please manually call:"
        echo "  service `basename $0` stop"
        echo "  service `basename $0` start"
        echo
        RETVAL=$?
}
<snip>
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        dostatus
        ;;
  restart|reload)
        restart
        ;;
  condrestart)
        condrestart
        ;;
  *)
        gprintf "Usage: `basename $0` {start|stop|status|restart|reload|condrest
art}\n"
        exit 1
esac

I suspect that if I changed it to look like:
  restart|reload)
        stop
        start
        ;;

Then that might make it work properly (because it spawns one less shell
in the whole process.

Feedback welcome.

Blue skies...           Todd
-- 
  Todd Lyons -- MandrakeSoft, Inc.   http://www.mandrakesoft.com/
UNIX was not designed to stop you from doing stupid things, because 
  that would also stop you from doing clever things. -- Doug Gwyn
   Cooker Version mandrake-release-8.3-0.2mdk Kernel 2.4.18-19mdk

Attachment: msg66178/pgp00000.pgp
Description: PGP signature

Reply via email to