RE: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Caldarale, Charles R
> From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> Subject: Re: tomcat shutdown: catalina.sh STOP vs SIGTERM
> 
> I'm not sure why it would take 20-30 seconds for you to see 
> the above message: it should be immediate.

One possible cause is specifying a large heap size in JAVA_OPTS, which will be 
used by both the running Tomcat and the JVM launched by the shutdown script.  
Better to put such settings in CATALINA_OPTS, which is not used by the shutdown 
script.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY 
MATERIAL and is thus for use only by the intended recipient. If you received 
this in error, please contact the sender and delete the e-mail and its 
attachments from all computers.


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__


Re: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Christopher Schultz
-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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Konstantin Kolinko
2010/3/8 Aggarwal, Ajay :
> When I send SIGTERM to tomcat, I actually do get
>

Tomcat installs a shutdown hook into JVM so that it will shutdown gracefully.

There is a problem though that if there are several shutdown hooks
then they run in parallel. That is particularly visible in 6.0.24,
because logging system shutdown was made more robust.

This shutdown hooks race is already fixed in the current 6.0.x sources
-- that will be 6.0.26.

Best regards,
Konstantin Kolinko

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



RE: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Aggarwal, Ajay
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

and,

2) my servlets destroy() methods do get called.

That’s why I suspect that even SIGTERM seems to bring tomcat down in an orderly 
manner. I should mention that I am on a linux platform, running tomcat 6.0.20.

As to why on a busy system, "catalina.sh stop" takes longer I really don't have 
the details. 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.

-Ajay


-Original Message-
From: Christopher Schultz [mailto:ch...@christopherschultz.net] 
Sent: Monday, March 08, 2010 1:33 PM
To: Tomcat Users List
Subject: Re: tomcat shutdown: catalina.sh STOP vs SIGTERM

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ajay,

On 3/8/2010 12:53 PM, Aggarwal, Ajay wrote:
> Sometimes on a busy system I have seen that "catalina.sh stop" does take
> a long time to shutdown tomcat.

You might want to investigate why this is happening: my Tomcat instances
(we have 4 in production) take only a few seconds to shut down completely.

> We are running another "monitoring
> service" on the system that monitors tomcat and few other system
> services. After issuing "catalina.sh" and waiting for some time (up to
> 25 seconds) it loses patience and gives a SIGTERM to tomcat process.
> SIGTERM seems to bring tomcat down much faster.

:)

> What is  the downside of using SIGTERM, if any?

I tried issuing a SIGTERM to my JVM/Tomcat process running in
development, and I got some messages in the app log file that indicated
that the webapp was coming down. But, I didn't get any "shutting down"
messages in catalina.out which leads me to believe that the shutdown
wasn't entirely clean.

> It does seem to bring
> tomcat down in an orderly manner and much faster than "catalina.sh
> stop".

Well, definitely faster, but I'm not sure about orderly: you should
check to see what things aren't stopping and determine if they are
potentially disastrous it TERMinated.

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

iEYEARECAAYFAkuVQt8ACgkQ9CaO5/Lv0PD8LgCdFbaGLq1nfsqJJb4dbAsKY8hT
lFEAoLUQHVzXZ9KnrQ79ExupS4cyKDfD
=vn8E
-END PGP SIGNATURE-

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



Re: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Hassan Schroeder
On Mon, Mar 8, 2010 at 9:53 AM, Aggarwal, Ajay
 wrote:

> What is  the downside of using SIGTERM, if any? It does seem to bring
> tomcat down in an orderly manner and much faster than "catalina.sh
> stop".

Yeah, "seem to" would be the operative phrase, I think.

A leap off a tall structure might "seem to" be much like flying. Initially. :-)

As Chris already said: check your app to see what's slow to exit, and
what the consequences of an ungraceful stop might be.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan

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



Re: tomcat shutdown: catalina.sh STOP vs SIGTERM

2010-03-08 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ajay,

On 3/8/2010 12:53 PM, Aggarwal, Ajay wrote:
> Sometimes on a busy system I have seen that "catalina.sh stop" does take
> a long time to shutdown tomcat.

You might want to investigate why this is happening: my Tomcat instances
(we have 4 in production) take only a few seconds to shut down completely.

> We are running another "monitoring
> service" on the system that monitors tomcat and few other system
> services. After issuing "catalina.sh" and waiting for some time (up to
> 25 seconds) it loses patience and gives a SIGTERM to tomcat process.
> SIGTERM seems to bring tomcat down much faster.

:)

> What is  the downside of using SIGTERM, if any?

I tried issuing a SIGTERM to my JVM/Tomcat process running in
development, and I got some messages in the app log file that indicated
that the webapp was coming down. But, I didn't get any "shutting down"
messages in catalina.out which leads me to believe that the shutdown
wasn't entirely clean.

> It does seem to bring
> tomcat down in an orderly manner and much faster than "catalina.sh
> stop".

Well, definitely faster, but I'm not sure about orderly: you should
check to see what things aren't stopping and determine if they are
potentially disastrous it TERMinated.

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

iEYEARECAAYFAkuVQt8ACgkQ9CaO5/Lv0PD8LgCdFbaGLq1nfsqJJb4dbAsKY8hT
lFEAoLUQHVzXZ9KnrQ79ExupS4cyKDfD
=vn8E
-END PGP SIGNATURE-

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