Blog

Monday, June 29, 2009
Unreliable Tomcat
Tomcat has had a memory leak for at least a decade that I am aware of. If you deploy by copying a war file to the webapps directory, sooner or later Tomcat runs out of memory. It's hard to kill tomcat when it's wedged in this way, since the standard way of shutting down is to send a request (via the shutdown script). If Tomcat is too ill to listen to requests, you can't shut it down. Usually the solution is to find its pid and kill it from the command line. How to automate this? That is, I want to reboot tomcat automatically, even when it's wedged. It sure would be nice if there was a pid file... Well, there can be a pid file. Set CATALINA_PID to the path to a pid file you want tomcat to use, and the catalina.sh script (called by startup.sh) will do the right thing. Then, in order to get shutdown.sh to make use of the pid file, simply stipulate -force.

Labels:

Post a Comment

Comments:

ps -ax | grep -i [t]omcat | awk '{ print "kill " $1 }' | sh

There you go. That will kill it.

 # posted by Anonymous Anonymous: 7:07 AM PDT

Um, thanks, Anonymous, but that's what I was trying to avoid. As I said in my post, I know how to "find its pid and kill it", but I want to automate it, hence I wanted to make use of the pid file mechanism already built into catalina.sh.

 # posted by Blogger jdtangney: 8:20 AM PDT

I attended a presentation by SpringSource in which a Tomcat guru, Filip Hanik recommended that due to leaks like you experienced, you shouldn't try and hot deploy an app by copying a war file.

 # posted by Anonymous Tim McGuire: 12:58 PM PDT

AddThis Feed Button

Twitter Updates

    follow me on Twitter

    Archives