tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Kujtan" <akuj...@evertz.com>
Subject RE: Shutdown Hooks not firing when tomcat is shutdown from within a webapp
Date Tue, 07 Feb 2012 19:40:31 GMT
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Tuesday, February 07, 2012 1:39 PM
> To: Tomcat Users List
> Subject: RE: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > From: Andrew Kujtan [mailto:akujtan@evertz.com]
> > Subject: Shutdown Hooks not firing when tomcat is shutdown from
> within a webapp
> 
> > OS: Windows 7  32bit
> > Ver.: Apache Tomcat/7.0.25
> > Jvm: 1.6.0_14-b08
> 
> Thanks for that.
> 
> > I am attaching a shutdown hook from within my webapp to log
> > some info after tomcat shuts down,
> 
> That really doesn't sound like a good idea at all.  I would think you
> should be using a ServletContextListener.
Unfortunately the actions need to happen after tomcat has shutdown, not
just my webapp.
> 
> > Can anyone tell me how to programmatically shut down tomcat
> > such that the hooks will still fire?
> 
> There's no real provision for doing so, since that's not a decision a
> webapp should be making. 

I agree, but I don't have a choice, boss says it must kill itself if
some scenario happens.

> There's always System.exit()...
> 
When I call System.exit() tomcat doesn't actually shutdown, it looks
like it just is deadlocking or something as I am getting a timeout on
the call that runs it. On the bright side System.exit() does trigger the
shutdown hook to be called, even though the server doesn't shut down, it
just becomes unresponsive but the process remains and is still bound to
all of its ports.

If I call both,

org.apache.catalina.startup.Bootstrap.main(new String[] { "stop"});
System.exit(0);

Tomcat shuts down, and my hook gets called, but I don't know how
ridiculous I want to take this already hacky thing...

Probably stupid question, but is calling System.exit() from a webapp
supposed to be able to kill tomcat?

>  - 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.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org


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


Mime
View raw message