On 09/12/2010 12:51, André Warnier wrote:
> 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.

You are missing d) Something triggers a kill -15 which is a *valid* way
to shut down Tomcat if it is user initiated.

There is no way to differentiate between b) and d). Further in case d)
there is no way to tell if it was initiated by a user (valid) or some
unexpected process (invalid). That is the problem here. Tomcat already
logs a). It is a given that there is no way to log c).

Mark


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

Reply via email to