tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: tomcat shutdown: catalina.sh STOP vs SIGTERM
Date Mon, 08 Mar 2010 23:24:18 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ajay,

On 3/8/2010 2:56 PM, Aggarwal, Ajay wrote:
> When I send SIGTERM to tomcat, I actually do get
> 
> 1) these messages in my catalina.out
> 
> Mar 8, 2010 2:46:05 PM org.apache.catalina.core.StandardService stop 
> INFO: Stopping service Catalina

That's good, but apparently not guaranteed to occur, since I didn't see
them in my environment. It's possible that the JVM sends a notification
and subsequently terminates all the threads, but may not wait for them
to finish their work.

I highly recommend an orderly shutdown (using "catalina.sh stop").

> As to why on a busy system, "catalina.sh stop" takes longer I really
> don't have the details.

This should be easy to determine: run "catalina.sh stop" which should
return immediately. Run "jstack" on the still-running JVM several times
a few seconds apart to see which threads are still alive. Perhaps some
are request processing threads still doing work, in which case the
response will not complete if you forceably kill the thread. There could
be other threads running that should be daemon threads but aren't:
that's usually a simple fix.

> All I can say is that sometimes I don't even
> see the above messages for first 20-25 seconds. Could it be because
> "catalina.sh stop" has to start another JVM and then send a "stop"
> message to tomcat process over a local loop interface and on a busy
> system, both of these require resources which may not be available.

Yes and no: "catalina.sh stop" does in fact start a second JVM and send
a "stop" message to the other Tomcat, but its likely that Tomcat
receives the message immediately. I'm not sure why it would take 20-30
seconds for you to see the above message: it should be immediate. Tomcat
then does a whole bunch of things, including waiting for request
processing threads to complete, notifying servlet context listeners that
the webapp is coming down, then taking the servlets and filters out of
service, shutting down various resource pools, etc. Only then does it
take the connectors out of service. So, if something takes a long time
to complete (maybe a filter or servlet taking a long time to shutdown)
then you'll just have to wait for it to complete.

I just checked, and my TC 6.0.20 install doesn't print anything after
"Stopping Service Catalina" when I shut it down, so it's possible that
message is printed when the service really is ready to go down.

Thread dumps will certainly help you figure out what's taking so long.

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

iEYEARECAAYFAkuVhyIACgkQ9CaO5/Lv0PBZBACfY+kevbW9Y51JNMrghofh4aCj
atwAn02La9O0OEY5bn3/9l+3NlHazxRG
=LQwd
-----END PGP SIGNATURE-----

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


Mime
View raw message