|
|
06.30.2004 |
|
||||||||||
| Tomcat Always On | ||||||||||||
I've been a computer geek since a boy, and thoughts related to computers and software engineering get dropped here for the benefit of humanity and my own hubris.
|
Just went through a mildly painful experience trying to get Tomcat (or any daemon for that matter) to run forever, and if it dies (Tomcat sometimes does), it should be restarted. Wanted to make some notes as I tend to forget things. First, grab a copy of Dan Bernstein’s daemontools and extract it… say in /usr/local/daemontools Like most Unix programs, it won’t compile right out of the box due to a bug in Dan’s code (see this note for details). However, it isn’t too difficult to get it to compile. Hop down into the directory: extern int errno; To the following: #include <errno.h> Now, you can compile the suckah by typing in To get tomcat working, grab these goods and extract the archive directly into the Basically, all you really need is to create a #!/bin/sh
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
export JAVA_OPTS="-Xmx1024M -Xms256M -server"
export TOMCAT_HOME=/usr/local/tomcat
exec 2>&1
exec setuidgid tomcat ${TOMCAT_HOME}/bin/catalina.sh run
Now you probably know enough to get any other service running. BTW: Just by executing the Thought originally posted on Wednesday, 30 June 2004
© 2004-2006, Howard Abrams • Except where otherwise noted, all original content is licensed under a Creative Commons License (see details). A comment to this from Howard the Author
These daemontools are not very well documented, but if you need to stop or restart Tomcat (or any other service that you have running under these tools), the command to call is: svc -d /service/tomcat This svc program, I guess, does most of the controlling, and it has the following options:
A comment to this from the Author
Ugh. I’m not so sure I like this daemontools. It doesn’t seem to be the most reliable thing. Granted, it could just be that it can’t quite understand Java processes, for this evening it magically decided that our Tomcat wasn’t running, so it started another one… and then another one… Hmm… maybe I will just create a script that doesn’t run Tomcat as a background process (like the catalina.sh script does) and then place that script in the /etc/inittab file. A bit unorthodox, but … I’m not really a system administrator. I just play one on TV. Comment posted on Monday, 5 July 2004A comment to this from Peter
Hi, the daemontools depend on the runscript not to exit if everything is ok and catalina.sh does.. so there you go. Have you allready found a way to not run tomcat in the background? Peter Comment posted on Wednesday, 18 August 2004A comment to this from Peter
Oeps sorry, its very simple: just call catalina.sh with run instead of start… Comment posted on Wednesday, 18 August 2004 |
|||||||||||
|
||||||||||||