Monday, January 09, 2006

Brutal Tomcat Shutdown

We have a copy of tomcat that is used here in Oxford for our automatic testing and it regularly runs out of memory due to the frequent reloads as the classloader memory not getting cleaned out. To prevent this from happen I attempted to restart tomcat every night in a cron job:

0 3 * * * ($HOME/tomcat/bin/ stop -force > /dev/null; sleep 10; $HOME/tomcat/bin/ start > /dev/null)

However it seemed that this was not working, the -force option was supposed to kill the tomcat process after attempting to shut it down gracefully. After reading through the script I discovered that I needed to set the CATALINA_PID variable for the -force to work. It would be nice if catalina would warn when you use the -force option without having a PID file.