Mark Thomas wrote:
On 08/12/2010 23:23, André Warnier wrote:
Mark Thomas wrote:
Been there, tried that. There is no easy way (I could find) to
distinguish between a legitimate and illegitimate shut-down.

Naive suggestion : how about some global flag which the legitimate
shutdown paths set (and the others don't know about), and which the
"hook" in question checks ?

As I said, been there, tried that.

You can log when the shutdown command is used (Tomcat 7 does) but there
is no way to distinguish between a kill -15 and code calling
system.exit() (unless you run with a security manager as already discussed).

Maybe what I suggested was misunderstood.
The point was not to catch and label the unexpected reasons for stopping.
The point was to clearly label the expected and "legal" ones.
E.g.
- Tomcat starts.  Flag string is set to "*unexpected shutdown*".
- ... tomcat runs
then either

a) Tomcat told to shutdown by a "legal" part of the code.
Before that legal part of the code issues the shutdown signal, it resets the flag string to "hey, it's me who did that"
OR
b) Tomcat told to shutdown by some application doing a System.exit(). That application does not reset the string, so it remains at "*unexpected shutdown*".
OR
c) Tomcat blown out of the water by a kill -9 to its JVM.  No logs, nothing.

Then, if the Coyote Connector shutdown code runs, it picks out the value of the flag, and dumps it to the logfile.

In case (a), when then have a proper trace in the logs of who decided to 
shutdown.
In the others, we don't, so *we know* that it was not one of the "legal" ones, and we can tell the OP for sure that it was not Tomcat code who did it.

Does that make sense ?



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

Reply via email to