-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Chaitanya,

On 7/20/17 2:40 PM, Chaitanya Sabbineni wrote:
> Hi All,
> 
> This is to add that I found some interesting thing. I order to
> enable debugging in tomcat I changed the logging level from Fine to
> Finest .Upon changing the log level we see that tomcat is not
> getting stopped on its own.This is he strange behaviour we
> observed.
> 
> can you please elaborate what actually this mean
> 
> Fix your application so that the Tomcat JVM exits cleanly

Yes this would certainly be a good thing to do.

> Use a thread pool. Manage the thread pool in a servlet context
> listener (creation, destruction).
> 
> can you let me know is there any way way to kill the timer thread
> during the stop of tomcat.
> 
> And can you let me know what actually the timer thread task in the
> error log.I mean if can point me to that snippet.

There are many way to create a timer in Java. Usually it's either your
code, or some code in a library you use. You will have to determine
where the timer is being created, and how to shut it down.

All good libraries that launch timers have some kind of "shut down"
command you can give to them. You just need to make sure that when
your application is being shut-down, you make sure to shut-down all of
the various timers that may be running.

Usually something like this:

public class TimerKiller implements ServletContextListener {
    public void init(ServletContext ctx) { }
    public void destroy(ServletContext ctx) {
        org.library.timer.TimerManager.shutdown();
    }
}

That's very hypothetical... you will need to research each of the
timer threads that are running, determine how to shut them down, and
then implement a ServletContextListener (and configure it in web.xml!)
that calls the right method(s) to shut-down those timers.

- -chris

> On Thu, 20 Jul 2017 11:37 pm Mark Eggers,
> <its_toas...@yahoo.com.invalid> wrote:
> 
>> Chaitanya,
>> 
>> This will be long and somewhat speculative.
>> 
>> On 7/20/2017 9:00 AM, Christopher Schultz wrote:
>>> Chaitanya,
>>> 
>>> On 7/20/17 11:03 AM, Chaitanya Sabbineni wrote:
>>>> Stop script in the sense it's Catalina script only but we
>>>> usually stop tomcat using the command Catalina.sh stop. But
>>>> in our case we are not manually executing this script to stop
>>>> tomcat and tomcat is stopping on its own.
>>> 
>>>> our main problem here us tomcat is stopping on its own and it
>>>> needs a restart.
>>> 
>>> Right.
>>> 
>>>> If I understand you correct you are telling TimerThread that
>>>> does not stop when the application is shut down. Can you let
>>>> me know what actually the timer thread mean. And moreover if
>>>> the timer thread didn't stop ideally tomcat shouldn't stop
>>>> but in our case it's stopping.
>>> 
>>> Tomcat is stopping but the JVM is not. If your application were
>>> to shut-down cleanly, then the JVM would exit as well. This is
>>> unrelated to your real problem (unexpected Tomcat shutdown),
>>> but you might want to look into fixing that, because it makes
>>> your application impossible to reload without risking serious
>>> heap space problems.
>>> 
>>>> Yes my question is why Tomcat is being shut down at all.
>>> 
>>>> Yes when ever tomcat is stopping on own(not daily) it stops
>>>> at 02:00 . You mentioned that your  guess is that we are
>>>> using a service runner that is configured to bounce your
>>>> services at 02:00.Can let me know what this service runner is
>>>> and how to check it.
>>> 
>>> I know nothing about your environment. Until you mentioned 
>>> "catalina.sh stop" above, I didn't even know you were on a
>>> UNIX-like environment. Honestly, I assumed you were on Windows
>>> because "mysterious service stoppage" has Microsoft Windows
>>> behavior written all over it.
>>> 
>>> There are two ways to trigger a Tomcat shut down:
>>> 
>>> 1. Send a TERM signal to the process 2. Connect to Tomcat's
>>> shutdown listener (default: port 8005) and give the shutdown
>>> command (default: "SHUTDOWN")
>>> 
>>> You can eliminate one of those possibilities by setting the
>>> shutdown port in server.xml to "" (empty) which will disable
>>> this type of shutdow n:
>>> 
>>> <Server port="" ...
>>> 
>>> You cannot disable the other type of shutdown... any user on
>>> the system who can send a TERM signal to your process could
>>> terminate Tomcat .
>>> 
>>> As for catching whoever is shutting down your Tomcat, you may
>>> want to look at who has administrative access to your server,
>>> and who has access to the user running your Tomcat server.
>>> 
>>> Check your syslog to find sudo and cron events that might be 
>>> automatically shutting-down Tomcat.
>>> 
>>> If you want to catch a TCP connection, you will likely have to
>>> enable tcpwrappers, iptables, ipfw, etc. to log connections to
>>> port 8005. Those logs will only tell you that the command is
>>> being sent, not who is sending it.
>>> 
>>> -chris
>> 
>> I am going to go out on a limb here and try to explain things.
>> Please note that this is all based upon reading between the
>> lines, and may not at all reflect what is actually going on.
>> 
>> Overview --------
>> 
>> I suspect the following:
>> 
>> 1. Logrotate of catalina.out at 2 AM 2. Tomcat JVM fails to exit,
>> then restart
>> 
>> Detail ------
>> 
>> 1. Logrotate (or other log rotation utility)
>> 
>> There are several ways that one can use to rotate catalina.out.
>> See the following:
>> 
>> https://wiki.apache.org/tomcat/FAQ/Logging#Q10
>> 
>> Some system admins actually stop Tomcat, rotate the logs, and
>> then start Tomcat. This has the advantage over the logrotate's
>> copytruncate option in that there is no possibility of partial
>> log entries.
>> 
>> 2. JVM fails to exit
>> 
>> From your error log, you have a TimeerTask thread that is not
>> shutting down. This prevents the JVM from exiting (see Chris's
>> comments). I suspect that this then prevents the start script
>> from starting Tomcat again (depending on the script).
>> 
>> Solutions ---------
>> 
>> 1. Fix your application so that the Tomcat JVM exits cleanly
>> 
>> Use a thread pool. Manage the thread pool in a servlet context
>> listener (creation, destruction).
>> 
>> This should be done in addition to anything else.
>> 
>> 2. Talk to your system admin to see if log rotation is being
>> used
>> 
>> Use copytruncate with logrotate rather than stopping and starting
>> the Tomca service.
>> 
>> This is assuming that you're using logrotate, and that there is
>> a logrotate process that kicks off every morning at 2 AM.
>> 
>> 3. Use another method for rotating catalina.out
>> 
>> There are other methods for rotating catalina.out mentioned in
>> the link above.
>> 
>> Again, this is assuming that your system admin has implemented
>> some log rotation which is causing the problem.
>> 
>> 4. See Chris's comments above concerning potential security
>> issues
>> 
>> Finally -------
>> 
>> Your catalina.out file should be small, and consist of startup / 
>> shutdown messages from Tomcat. Other (application) information
>> should go into application-specific log files. This means that
>> you should implement some sort of logging for your applications.
>> 
>> In other words, there should be little need to periodically
>> rotate catalina.out.
>> 
>> . . . just my two cents /mde/
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJZch4KAAoJEBzwKT+lPKRYl9wP/iJstzt2Yoymcvm0R3xeXL+B
W3S+U9L93PT4DTs9e/1wEvCDCAudwebmhNuTAqHtgwdm65LAJ06eQwRsPpIeYXUB
m+Ja5Pc4wM3bIDMupO3KBACiW2cAJ665oOQCf28R1RFqrgKJy8bn/yYxPXQBMCs1
JXA4AhjQvQTogap/DoPRv9HTEK9pO9SRdkPam+p3ahjJoPijFGDY8kgzP7IMtS2/
lKXnipfdX3NS7ngqcXu1ThsWvZmK2+CRLn4IIBht37S+nU0NaG4T+5m2Q1cGxfXi
zpMg6NnwB3EBpy4KLJYSloOCSsd20JIiKQibgunKLvXKkc073f3avXEljVOICSI8
UcGEIWWQHo8XjDvQ3+eFK6E9y6C2FL9YqzXyPDZ/HvB5nQx4f8BwL87D/nevW9jO
s8Xs/2BC1LOMYmjzBkyro8Q3nsWUneYBROM5MX74k+OyxVf8o93f+TV/8sdQdBy4
DNXh3z/7cIG3PesLYgx4NTAthlGbe5XBJBXAdhJMGOWNq2YC8ISh/tV+MeLcIpEC
qsKkITlA+PlKX6iK6bKB+fpE3/GkUUn+GFFyZyCLghPxkVcWvd5yHz1CfmiR+Tkz
7ebyBBMEIQ2Jipxb4v/4u9Xs0CpCg/g54YeaKCg7W3Sy0p83BZGv/El3Zndto7MP
pc0DBU0spS2GOiUxNkIp
=F41+
-----END PGP SIGNATURE-----

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

Reply via email to