You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Derek Alexander <D....@lse.ac.uk> on 2007/09/06 17:41:00 UTC

synchronous stop of tomcat

Using: 
$CATALINA_HOME/bin/catalina.sh stop
$CATALINA_HOME/bin/catalina.sh start
in quick succession to restart Tomcat,
it is possible that the start operation will run before all ports have been
released by the instance I'm stopping.

Is there a synchronous method for stopping Tomcat, i.e. one that won't
return until the ports have been released at least?

Cheers,
Derek
-- 
View this message in context: http://www.nabble.com/synchronous-stop-of-tomcat-tf4392954.html#a12525265
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: synchronous stop of tomcat

Posted by Derek Alexander <D....@lse.ac.uk>.
I was meaning that it appears you can add a listener directly to the Server
element (AFAIU from the code anyway).

<Server ...>
   <Listener ... />
   ...


> Not synchronous? Aren't notifications almost always synchronous? 

Yes, the notification would be synchronous but the call to stop is still
asynchronous. Would get the job done though.
you

> you could touch a file or something like that. 

That would be a nice simple way of doing it. Will give that a shot on
Monday.

Cheers,
Derek
-- 
View this message in context: http://www.nabble.com/synchronous-stop-of-tomcat-tf4392954.html#a12558158
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: synchronous stop of tomcat

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

Derek,

Derek Alexander wrote:
> Have been looking at the source, although not documented (for TC5.5), it
> seems that it is possible to nest a Listener element
> (org.apache.catalina.LifecycleListener) under the Server element as 
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html described here
> for nesting within Context elements.

I don't think you want this on a Context... you'd be getting events when
the webapp was taken out of service (even during a re-reploy) rather
than when the server was going down.

> This could be used to provide a more elegant way of receiving notification
> of when the server has stopped.

If it can really notify you as TC is going down, that would be good: you
could touch a file or something like that.

> However, still not synchronous, looking at JMX for that, seems like I just
> need to invoke StandardServer.stop()

Not synchronous? Aren't notifications almost always synchronous?

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

iD8DBQFG4XK49CaO5/Lv0PARAtESAJwP+Gf+RoGjLVGI7JiwTaEPCK5GmwCglbHF
G45V5/IVG+K4ofeHdc5F2yw=
=8eI6
-----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


Re: synchronous stop of tomcat

Posted by Derek Alexander <D....@lse.ac.uk>.
Have been looking at the source, although not documented (for TC5.5), it
seems that it is possible to nest a Listener element
(org.apache.catalina.LifecycleListener) under the Server element as 
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html described here
for nesting within Context elements.
This could be used to provide a more elegant way of receiving notification
of when the server has stopped.

However, still not synchronous, looking at JMX for that, seems like I just
need to invoke StandardServer.stop()


Christopher Schultz-2 wrote:
> 
>> Is there a synchronous method for stopping Tomcat, i.e. one that won't
>> return until the ports have been released at least?
> 
> Not that I know of. Lots of folks have posted to the list somewhat
> recently asking basically the same question: how do you know when Tomcat
> has really stopped?
> 
> The best hack I've heard of is to watch the catalina.out log file for
> the magic "Tomcat Stopped" message. Another option would be to actually
> poll the port to see if it's available. They're both pretty ugly options.
> 
> - -chris
> 

-- 
View this message in context: http://www.nabble.com/synchronous-stop-of-tomcat-tf4392954.html#a12553588
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: synchronous stop of tomcat

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

Derek,

Derek Alexander wrote:
> Using: 
> $CATALINA_HOME/bin/catalina.sh stop
> $CATALINA_HOME/bin/catalina.sh start
> in quick succession to restart Tomcat,
> it is possible that the start operation will run before all ports have been
> released by the instance I'm stopping.

Yes.

> Is there a synchronous method for stopping Tomcat, i.e. one that won't
> return until the ports have been released at least?

Not that I know of. Lots of folks have posted to the list somewhat
recently asking basically the same question: how do you know when Tomcat
has really stopped?

The best hack I've heard of is to watch the catalina.out log file for
the magic "Tomcat Stopped" message. Another option would be to actually
poll the port to see if it's available. They're both pretty ugly options.

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

iD8DBQFG4HYN9CaO5/Lv0PARAhdOAJ4y5YoCK10SuLvAp/xbaBC35jvlbgCgv01O
giDep97OsHCWtx/OBoGzbf0=
=3cJP
-----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