Hello,

I have searched inside TOMCAT (for the moment version 10.1.x but seems to be 
present in all versions) how to stop TOMCAT during INITIALIZATION phase and I 
can't find any method how to do it.

Tomcat seems to have 3 ways to stop it:
1. Sending SHUTDOWN command over the control port socket (the most traditional 
one)
2. Sending SIGTERM signal to java process because I see that 
org/apache/catalina/startup/Catalina.java registers a java shutdown hook that 
basically stop's the server container
3. calling manager jmxproxy via HTTP and invoke stop on server container

The problem of solution 1 and 2 is that these ways are available only after 
initialization of toncat is complete (the second one I never been able to use 
it but seems to me from code that is available only after initialization when 
is logged the message that says " INFO [main] 
org.apache.catalina.startup.Catalina.start Server startup in [26102] 
milliseconds").
Solution 3 is also available after initialization because manager web 
application is scheduled to startup after our web application and tomcat seems 
to pause http requests until initialization is complete.

So I am not able to send any signal to shutdown tomcat during this 
initialization phase or I can't figure out how to do it.

The reason we want this is as follows:
Our application consists of a TOMCAT instantance that run's inside our WAR web 
application together with manager, host manager and default ROOT tomcat 
delivered web applications (the root application is modified to redirect to our 
web application).
Our war application takes aprox 20 - 30 seconds to startup and the majority of 
time is spent inside few servlet context listeners and stops quickly in 
gracefull manner.

We also have some custom made wrapper bash scripts that start / stop tomcat 
like this:
- the start script delegates the start procedure to bin/catalina.sh tomcat 
script with run parameter (after setting environment and other things)
- the stop script delegates the stop procedure to bin/shutdown.sh tomcat script 
(after setting environment and other things)

Due to the fact that initialization takes a visible long time, it is possible 
to need to stop tomcat in this phase for the following reasons:
1. the administrator wishes to interrupt this initialization
2. the operating system is shutdown gracefully during initialization of tomcat 
and tomcat, like any process, need to start a shutdown during any phase

Our question is:
1. It is possible to stop tomcat during initialization phase?
2. If yes how and if not are any plans to implement it in future versions?

It seems to me that my solutions for now are:
1. sending SIGKILL signal to tomcat (this is very risky to me because stopping 
like this in the middle of something may corrupt data - but this situation is 
any way possible so I have to handle it)
2. wait for tomcat initilization procedure to finish and then trigger the 
shutdown since we can do something in our wrapper scripts
Do you see any other possible solutions?


Thanks.


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

Reply via email to