You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Maxim Veksler <ma...@gmail.com> on 2008/10/15 16:59:34 UTC

Programmatic instruct Tomcat to shutdown

Hello,

I would like to forcefully cause my application server to fail once I
discover a situation I can't recover from. We have HA that should handle the
situation from there.

The best way I can see this happening is by issuing a shutdown instruction
to the container, but I can't find how to do this "peacefully". I tried the
System.exit(1) trick but this keeps running threads active because they do
not get the shutdown notification.

How should I properly call server shutdown from my webapp ?


Thank you,
Maxim.

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

Re: Programmatic instruct Tomcat to shutdown

Posted by Leon Rosenberg <ro...@googlemail.com>.
On Thu, Oct 16, 2008 at 1:31 PM, Maxim Veksler <ma...@gmail.com> wrote:
> On Wed, Oct 15, 2008 at 21:07, Filip Hanik - Dev Lists
> <de...@hanik.com>wrote:
>
>> you mean like
>>
>> java.lang.System.exit(1);
>>
>>
> Not quite.
>
> I've commented that I've tried System.exit(1); and it's fails because I have
> threads that aren't going down by this instruction. The need the Servlet
> notification of a shutdown event.
>
> That's the reason for my query of doing "ordered shutdown".
>
> Thank you for your help.

u mean as in
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
Leon

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


Re: Programmatic instruct Tomcat to shutdown

Posted by Maxim Veksler <ma...@gmail.com>.
On Wed, Oct 15, 2008 at 21:07, Filip Hanik - Dev Lists
<de...@hanik.com>wrote:

> you mean like
>
> java.lang.System.exit(1);
>
>
Not quite.

I've commented that I've tried System.exit(1); and it's fails because I have
threads that aren't going down by this instruction. The need the Servlet
notification of a shutdown event.

That's the reason for my query of doing "ordered shutdown".

Thank you for your help.


>
> Filip


Maxim.


>
>
> Maxim Veksler wrote:
>
>> Hello,
>>
>> I would like to forcefully cause my application server to fail once I
>> discover a situation I can't recover from. We have HA that should handle
>> the
>> situation from there.
>>
>> The best way I can see this happening is by issuing a shutdown instruction
>> to the container, but I can't find how to do this "peacefully". I tried
>> the
>> System.exit(1) trick but this keeps running threads active because they do
>> not get the shutdown notification.
>>
>> How should I properly call server shutdown from my webapp ?
>>
>>
>> Thank you,
>> Maxim.
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

Re: Programmatic instruct Tomcat to shutdown

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
you mean like

java.lang.System.exit(1);


Filip


Maxim Veksler wrote:
> Hello,
>
> I would like to forcefully cause my application server to fail once I
> discover a situation I can't recover from. We have HA that should handle the
> situation from there.
>
> The best way I can see this happening is by issuing a shutdown instruction
> to the container, but I can't find how to do this "peacefully". I tried the
> System.exit(1) trick but this keeps running threads active because they do
> not get the shutdown notification.
>
> How should I properly call server shutdown from my webapp ?
>
>
> Thank you,
> Maxim.
>
>   


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


Re: Programmatic instruct Tomcat to shutdown

Posted by Maxim Veksler <ma...@gmail.com>.
On Fri, Oct 17, 2008 at 23:07, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Maxim,
>
> Maxim Veksler wrote:
> > I would like to forcefully cause my application server to fail once I
> > discover a situation I can't recover from. We have HA that should handle
> the
> > situation from there.
> >
> > The best way I can see this happening is by issuing a shutdown
> instruction
> > to the container, but I can't find how to do this "peacefully".
>
> You should check out the code for the Bootstrap class:
>
>
> http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_18/java/org/apache/catalina/startup/Bootstrap.java
>
> It calls o.a.c.s.Catalina.stopServer which you can read here:
>
>
> http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_18/java/org/apache/catalina/startup/Catalina.java
>
> Basically, it makes a localhost socket connection and send the
> "shutdown" command to the server. You could do this yourself to initiate
> a graceful server shutdown.
>

I will do that, thank you Chris.

>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkj4/qkACgkQ9CaO5/Lv0PCA7wCgouK/jWSeZODHtufCB6prywDS
> v+kAoK3bBmoq86awNLxhw3SMhmBgjvmg
> =98T3
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

Re: Programmatic instruct Tomcat to shutdown

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maxim,

Maxim Veksler wrote:
> I would like to forcefully cause my application server to fail once I
> discover a situation I can't recover from. We have HA that should handle the
> situation from there.
> 
> The best way I can see this happening is by issuing a shutdown instruction
> to the container, but I can't find how to do this "peacefully".

You should check out the code for the Bootstrap class:

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_18/java/org/apache/catalina/startup/Bootstrap.java

It calls o.a.c.s.Catalina.stopServer which you can read here:

http://svn.apache.org/repos/asf/tomcat/tc6.0.x/tags/TOMCAT_6_0_18/java/org/apache/catalina/startup/Catalina.java

Basically, it makes a localhost socket connection and send the
"shutdown" command to the server. You could do this yourself to initiate
a graceful server shutdown.

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

iEYEARECAAYFAkj4/qkACgkQ9CaO5/Lv0PCA7wCgouK/jWSeZODHtufCB6prywDS
v+kAoK3bBmoq86awNLxhw3SMhmBgjvmg
=98T3
-----END PGP SIGNATURE-----

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