You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Costin Manolache <cm...@yahoo.com> on 2003/02/10 21:04:08 UTC

RE: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Craig R. McClanahan wrote:

> It is OK for web applications to start threads -- as long as the web
> application cleans up after itself when the application is shut down (the
> easiest way to detect that is to create a ServletContextListener and wait
> for the contextDestroyed() method of your listener to be called).
> 
> The JVM running Tomcat shuts down when all non-daemon threads have been
> killed.  Tomcat properly cleans up all the threads that *it* creates -- it
> is up to your application to do the same.

I can backport the "-force" option from 3.3 - basically save the PID and 
then use kill if tomcat doesn't shut down gracefully.

Fact is many apps are not cleaning up - and having the whole server hunged 
and unable to restart for one bad app is not good.

Costin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by ml...@zip.com.au.
On Mon, Feb 10, 2003 at 12:04:08PM -0800, Costin Manolache wrote:
> I can backport the "-force" option from 3.3 - basically save the PID and 
> then use kill if tomcat doesn't shut down gracefully.

Yes, please!!

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Definitely a more portable suggestion.

Tim Funk <fu...@joedog.org> writes:

> Why is a kill done instead of a System.exit()?
> 
> Could instead a background daemon thread be launched, then be made to
> sleep for 30(?) second. If the thread wakes up then the tomcat has not
> exited properly and System.exit() can be called?
> 
> 
> Since this class would live in /common or /server - it should be
> allowed to call System.exit()? Then one could configure a new entry in
> <Server> to choose how long to wait before calling System.exit, for
> example:
> 
> 
> <Server port="8005" shutdown="SHUTDOWN" debug="0" shutdownWait="30">
> 
> Unless this seems like a bad idea - I can make an attempt to code and
> test it.
> 
> 
> -Tim
> 
> Costin Manolache wrote:
> > Craig R. McClanahan wrote:
> >
> 
> >>It is OK for web applications to start threads -- as long as the web
> >>application cleans up after itself when the application is shut down (the
> >>easiest way to detect that is to create a ServletContextListener and wait
> >>for the contextDestroyed() method of your listener to be called).
> >>
> >>The JVM running Tomcat shuts down when all non-daemon threads have been
> >>killed.  Tomcat properly cleans up all the threads that *it* creates -- it
> >>is up to your application to do the same.
> > I can backport the "-force" option from 3.3 - basically save the PID
> > and then use kill if tomcat doesn't shut down gracefully.
> 
> > Fact is many apps are not cleaning up - and having the whole server
> > hunged and unable to restart for one bad app is not good.
> 
> > Costin
> 
> > ---------------------------------------------------------------------
> 
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 

-- 

Daniel Rall <dl...@finemaltcoding.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Michael Smith <ms...@speedlegal.com>.
Tim Funk wrote:
> Why is a kill done instead of a System.exit()?

System.exit() is a cleaner solution, but there are plenty of cases where 
tomcat won't shut down at all with this solution, so a kill is needed 
(either as suggested, or manually/externally). For example, I had a bug 
in a webapp a while ago (the servlet was marked as load-on-startup, so 
it was starting up before tomcat was fully running) where the servlet 
was hanging, so tomcat never fully started up. As a result, it wasn't 
listening on the shutdown socket, so anything requiring in-process 
intervention such as System.exit() would fail.

Perhaps have both?




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Tim Funk <fu...@joedog.org>.
My plan was to add to Server attribute of shutdownWait(or something else 
if someone else has a better suggestion). If greater than zero, then 
System.exit() would be called otherwise, do nothing. That way - we are 
backwards compatible.

Die in 30 seconds
<Server port="8005" shutdown="SHUTDOWN" debug="0" shutdownWait="30">

Don't Die
   <Server port="8005" shutdown="SHUTDOWN" debug="0" shutdownWait="-1">
or
   <Server port="8005" shutdown="SHUTDOWN" debug="0" shutdownWait="0">
or
   <Server port="8005" shutdown="SHUTDOWN" debug="0">

-Tim

Craig R. McClanahan wrote:
> 
> On Mon, 10 Feb 2003, Tim Funk wrote:
> 
> 
>>Why is a kill done instead of a System.exit()?
> 
> 
> System.exit() is absolutely the wrong answer if Tomcat is embedded into a
> larger server-side application, rather than run separately in the usual
> way.  At best, you would need to make this configurable somehow (with the
> default to *not* run System.exit()).
> 
> Craig
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: [PATCH] Allow System.exit to be called on shutdown [was Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Tim Funk <fu...@joedog.org>.
Here is my jsp test case (again .. sigh) - I had to rename it to txt 
file so mozilla would attach it.


-Tim

[PATCH] Allow System.exit to be called on shutdown [was Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Tim Funk <fu...@joedog.org>.
Here is the patch to StandardServer.java and LocalStrings.properties.

Synopsis:
  New property: shutdownWait if greater than zero. Then to the end of 
shutdown, a new daemon thread is created which sleeps for {shutdownWait} 
seconds. When (and if) the Thread wakes back up, it prints to 
System.out() then new message in LocalStrings.properties and then calls 
System.exit.

shutdownWait defaults to zero. If zero or neagtive, then it is ignored 
and the old behavior occurs. (Which is to do nothing extra)

This patch was from tomcat5.

If this is good enough to accept, I can later submit the patches for the 
admin app and mbeans-descriptors.xml.

Also attached is the JSP I used to ensure the server stayed running. 
Ignore the quality of the jsp - its just a test.


-Tim


Craig R. McClanahan wrote:
> 
> On Mon, 10 Feb 2003, Tim Funk wrote:
> 
> 
>>Why is a kill done instead of a System.exit()?
> 
> 
> System.exit() is absolutely the wrong answer if Tomcat is embedded into a
> larger server-side application, rather than run separately in the usual
> way.  At best, you would need to make this configurable somehow (with the
> default to *not* run System.exit()).
> 
> Craig
> 

Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 10 Feb 2003, Tim Funk wrote:

>
> Why is a kill done instead of a System.exit()?

System.exit() is absolutely the wrong answer if Tomcat is embedded into a
larger server-side application, rather than run separately in the usual
way.  At best, you would need to make this configurable somehow (with the
default to *not* run System.exit()).

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Shutdown.sh does not work when long lasting operations, such as SQL Queries, are still active!

Posted by Tim Funk <fu...@joedog.org>.
Why is a kill done instead of a System.exit()?

Could instead a background daemon thread be launched, then be made to 
sleep for 30(?) second. If the thread wakes up then the tomcat has not 
exited properly and System.exit() can be called?

Since this class would live in /common or /server - it should be allowed 
to call System.exit()? Then one could configure a new entry in <Server> 
to choose how long to wait before calling System.exit, for example:

<Server port="8005" shutdown="SHUTDOWN" debug="0" shutdownWait="30">

Unless this seems like a bad idea - I can make an attempt to code and 
test it.

-Tim

Costin Manolache wrote:
> Craig R. McClanahan wrote:
> 
> 
>>It is OK for web applications to start threads -- as long as the web
>>application cleans up after itself when the application is shut down (the
>>easiest way to detect that is to create a ServletContextListener and wait
>>for the contextDestroyed() method of your listener to be called).
>>
>>The JVM running Tomcat shuts down when all non-daemon threads have been
>>killed.  Tomcat properly cleans up all the threads that *it* creates -- it
>>is up to your application to do the same.
> 
> 
> I can backport the "-force" option from 3.3 - basically save the PID and 
> then use kill if tomcat doesn't shut down gracefully.
> 
> Fact is many apps are not cleaning up - and having the whole server hunged 
> and unable to restart for one bad app is not good.
> 
> Costin
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org