I'm running Tomcat using the tomcat6 package from Ubuntu 9.04, which makes a daemon out of Tomcat using jsvc. I'd like to know the proper way to set Java heap options like -Xmx for Tomcat. I'd like to put the configuration wherever is most stylistically correct, and wherever is least likely to be overwritten by Ubuntu package updates.
The options I see right now:
- Hard-code them somewhere in /etc/init.d/tomcat6.
- Hard-code them somewhere in /usr/share/tomcat6/bin/catalina.sh.
- Create a line in /usr/share/tomcat6/bin/startup.sh to set CATALINA_OPTS to have the desired flags, and then export CATALINA_OPTS as an environment variable. (This looks like it will get picked up by catalina.sh.)
The last option sounds like the best one, and it's advocated (without explanation of why) at http://serverfault.com/questions/121038/increasing-javas-heapspace-in-tomcat-startup-script. But I wanted to get a second opinion. Anyone want to confirm that there isn't a better way?
-
The most elegant way I've found so far is to edit /etc/init.d/tomcat6 and add this at the top of the file:
# local config settings JAVA_OPTS="-Xms5000m -Xmx13000m
The other options I outlined in my question don't seem to work. After studying the script and experimenting some more, I now doubt that /usr/share/tomcat6/bin/catalina.sh and /usr/share/tomcat6/bin/startup.sh play any role in tomcat startup with the tomcat6 Ubuntu package. Instead; the /etc/init.d/tomcat6 completely replaces any work that might normally be done by catalina.sh/startup.sh.
I'm still a little worried about losing these config options in some future package update, but I guess if that happens it'd be pretty easy to restore them.
unhillbilly : Can this be set (exported) in the .bashrc for whatever user you want tomcat to run as ? [please excuse horrid grammar] That would survive updates to Tomcat package, etc. I'm assuming the "run-as" facility in init will start normal shell for that user and pick up the assignment. See also http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/From Chris -
At least on Ubuntu 10.04, /etc/init.d/tomcat6 sources /etc/default/tomcat6 if it exists. That's where I put my overrides, and I believe it's generally the "approved" way to make such changes.
From natacado
0 comments:
Post a Comment