You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Golden Planet Support <su...@goldenplanet.dk> on 2002/08/19 09:57:31 UTC

Modified "stop"-script for Linux

Hello All

I have noticed that the /etc/init.d/tomcat4 script still contains 
what is described as an "Ugly hack" - a short two second pause when 
restarting the service instead of something that confirms that all 
threads have been shut down.

A while ago I modified my own script to conatain the following lines -
 perhaps they could be of some use for others, I don't know. I am by 
no means an experienced coder so please bear with me if this is not 
the most elegant solution - it just works for me... ;-)

stop() {
    echo -n "Stopping $TOMCAT_PROG: "
    if [ -x /etc/rc.d/init.d/functions ]; then
        daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
    else
        su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
    fi
    RETVAL=$?
    echo

    echo 'Waiting for java threads to finish...'
    threads=1
    until [ $threads = '0' ]
		do
	    	ps -aux | grep $TOMCAT_USER -c > /tmp/threads
	    	read threads < /tmp/threads
    done
    rm -f /tmp/threads
    echo 'Java threads cleaned up - shutdown complete.'

    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 
/var/run/tomcat4.pid
}

The above works on a x86 RedHat 7.1 - I don't know if things may work 
differently on other systems.

--
Med venlig hilsen / Best regards

Anders C. Madsen

Golden Planet          Tel.: +45 7020 9594
Dalbygade 40           Fax.: +45 7020 9592
DK-6000  Kolding       http://www.goldenplanet.dk
--


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Modified "stop"-script for Linux

Posted by Henri Gomez <hg...@apache.org>.
Quoting Alex Chaffee / Purple Technology <gu...@stinky.com>:

> Thanks!  I added it to the recently-posted Bug 11754.  You may want to
> add yourself as a CC on this to track its progress.
> 
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11754

Thanks also.

I applied the patch to the 4.1.9 rpm I'm working on.

Stay tuned :)

>  - A
> 
> On Mon, Aug 19, 2002 at 09:57:31AM +0200, Golden Planet Support wrote:
> > Hello All
> > 
> > I have noticed that the /etc/init.d/tomcat4 script still contains 
> > what is described as an "Ugly hack" - a short two second pause when 
> > restarting the service instead of something that confirms that all 
> > threads have been shut down.
> > 
> > A while ago I modified my own script to conatain the following lines -
> >  perhaps they could be of some use for others, I don't know. I am by 
> > no means an experienced coder so please bear with me if this is not 
> > the most elegant solution - it just works for me... ;-)
> > 
> > stop() {
> >     echo -n "Stopping $TOMCAT_PROG: "
> >     if [ -x /etc/rc.d/init.d/functions ]; then
> >         daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
> >     else
> >         su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
> >     fi
> >     RETVAL=$?
> >     echo
> > 
> >     echo 'Waiting for java threads to finish...'
> >     threads=1
> >     until [ $threads = '0' ]
> > 		do
> > 	    	ps -aux | grep $TOMCAT_USER -c > /tmp/threads
> > 	    	read threads < /tmp/threads
> >     done
> >     rm -f /tmp/threads
> >     echo 'Java threads cleaned up - shutdown complete.'
> > 
> >     [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 
> > /var/run/tomcat4.pid
> > }
> > 
> > The above works on a x86 RedHat 7.1 - I don't know if things may work 
> > differently on other systems.
> > 
> > --
> > Med venlig hilsen / Best regards
> > 
> > Anders C. Madsen
> > 
> > Golden Planet          Tel.: +45 7020 9594
> > Dalbygade 40           Fax.: +45 7020 9592
> > DK-6000  Kolding       http://www.goldenplanet.dk
> > --
> > 
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > 
> 
> -- 
> Alex Chaffee                       mailto:alex@jguru.com
> jGuru - Java News and FAQs         http://www.jguru.com/alex/
> Creator of Gamelan                 http://www.gamelan.com/
> Founder of Purple Technology       http://www.purpletech.com/
> Curator of Stinky Art Collective   http://www.stinky.com/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Modified "stop"-script for Linux

Posted by Alex Chaffee / Purple Technology <gu...@stinky.com>.
Thanks!  I added it to the recently-posted Bug 11754.  You may want to
add yourself as a CC on this to track its progress.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11754

 - A

On Mon, Aug 19, 2002 at 09:57:31AM +0200, Golden Planet Support wrote:
> Hello All
> 
> I have noticed that the /etc/init.d/tomcat4 script still contains 
> what is described as an "Ugly hack" - a short two second pause when 
> restarting the service instead of something that confirms that all 
> threads have been shut down.
> 
> A while ago I modified my own script to conatain the following lines -
>  perhaps they could be of some use for others, I don't know. I am by 
> no means an experienced coder so please bear with me if this is not 
> the most elegant solution - it just works for me... ;-)
> 
> stop() {
>     echo -n "Stopping $TOMCAT_PROG: "
>     if [ -x /etc/rc.d/init.d/functions ]; then
>         daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
>     else
>         su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
>     fi
>     RETVAL=$?
>     echo
> 
>     echo 'Waiting for java threads to finish...'
>     threads=1
>     until [ $threads = '0' ]
> 		do
> 	    	ps -aux | grep $TOMCAT_USER -c > /tmp/threads
> 	    	read threads < /tmp/threads
>     done
>     rm -f /tmp/threads
>     echo 'Java threads cleaned up - shutdown complete.'
> 
>     [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 
> /var/run/tomcat4.pid
> }
> 
> The above works on a x86 RedHat 7.1 - I don't know if things may work 
> differently on other systems.
> 
> --
> Med venlig hilsen / Best regards
> 
> Anders C. Madsen
> 
> Golden Planet          Tel.: +45 7020 9594
> Dalbygade 40           Fax.: +45 7020 9592
> DK-6000  Kolding       http://www.goldenplanet.dk
> --
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Alex Chaffee                       mailto:alex@jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>