-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Marcoi,

On 10/5/2009 8:07 AM, Marcoi wrote:
> I have a servlet with the following code:
> 
> ==================================== for (int i = 0; i < 50; i++) { 
> System.out.println("waiting " + i); 
> Thread.currentThread().sleep(500); } PrintWriter writer =
> aResponse.getWriter(); writer.write("duh"); writer.flush(); 
> ====================================
> 
> and this is the output when I issue a request and then run
> ./shutdown.sh

[snip: evidence that the servlet doesn't survive the OP's expected 25
second lifespan]

Take a look at the unload() method in
http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_20/java/org/apache/catalina/core/StandardWrapper.java

You can see that Tomcat is rigged to wait a "reasonable" amount of time
for a servlet to complete before it is destroyed.

There is an "unloadDelay" member in that class that is apparently
inherited from the parent Container object (which is a Context) but
defaults to 2 seconds.

> As you can see it only waited for 3 seconds before taking down the
> server instead to let the request end.... is there a way to configure
> how long to wait?

If you look at the documentation for Context, you'll see that
"unloadDelay" is a configurable attribute of your webapp's <Context>
element:

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

Set this value to something longer than 2 seconds to allow your servlet
code more time to complete before the threads are killed.

Note that there does not seem to be a value to use for "wait forever" to
ensure that a request has been completed before shutting down. You'll
just have to set this value high enough to meet your needs.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrLXCgACgkQ9CaO5/Lv0PAXHQCgrqbTbg8AdYPIgCeUSGIlv5V8
Uw0AnRg3/n9RiahyRid884rl0GYKrJMU
=3g7C
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to