You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Bragg, Casey" <Ca...@allegiancetelecom.com> on 2000/07/19 20:40:01 UTC

Is there a signal I can listen to for Tomcat shutdown?

How can I determine when Tomcat is shutting down?  I'd like to run some
cleanup methods first.

Thanks...

...Casey

Re: Is there a signal I can listen to for Tomcat shutdown?

Posted by Alec Bau <Al...@msdw.com>.
JDK 1.3 also added "Runtime.addShutdownHook(Thread hook)" method. Hook
threads are run when JVM terminates (normally or abnormally) but before any
finalizes. There can be any number of different shutdown hooks registered
though the order of execution isn't guaranteed.

Thanks,
    Alec

"Craig R. McClanahan" wrote:

> "Bragg, Casey" wrote:
>
> > How can I determine when Tomcat is shutting down?  I'd like to run some
> > cleanup methods first.
> >
>
> The typical approach today is to have a load-on-startup servlet that is
> never actually called to serve requests.  The init() method of this
> servlet
> can be used to set up your resources in the first place, and the
> destroy()
> method can be used to clean up.  This relies on the fact that Tomcat
> won't
> unload the servlet in the mean time, which is true for Tomcat today but
> is
> not guaranteed behavior.
>
> The next version of the servlet spec will have more formal support for
> application startup and shutdown events.
>
> >
> > Thanks...
> >
> > ...Casey
>
> Craig McClanahan

Re: Is there a signal I can listen to for Tomcat shutdown?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Bragg, Casey" wrote:

> How can I determine when Tomcat is shutting down?  I'd like to run some
> cleanup methods first.
>

The typical approach today is to have a load-on-startup servlet that is
never actually called to serve requests.  The init() method of this
servlet
can be used to set up your resources in the first place, and the
destroy()
method can be used to clean up.  This relies on the fact that Tomcat
won't
unload the servlet in the mean time, which is true for Tomcat today but
is
not guaranteed behavior.

The next version of the servlet spec will have more formal support for
application startup and shutdown events.

>
> Thanks...
>
> ...Casey

Craig McClanahan