Answer
Unless you need the "status" functionality (that can be added, anyway), you can use 'catalina.sh' (for Tomcat 4.x) or 'tomcat.sh' (tomcat 3.x) directly for that.
ln -s /usr/local/tomcat/bin/tomcat.sh /etc/rc.d/init.d/tomcat
Then based on the runlevel, you can create the Sxx and Kxx links in the appropriate directory. For example, if your runlevel is 3, put the file in rc3.d:
ln -s /etc/rc.d/init.d/tomcat /etc/rc.d/rc3.d/S63tomcat
ln -s /etc/rc.d/init.d/tomcat /etc/rc.d/rc3.d/K37tomcat
(change S63 and K37 according to your starting sequence).
For Tomcat 4.0.x just change tomcat.sh with catalina.sh
Note: Remember to manually set CATALINA_HOME (for Tomcat 4.x) or TOMCAT_HOME (for Tomcat 3.x) and JAVA_HOME inside tomcat.sh, because I'm not sure that the shell script, if executes from there, will be able to guess the two variables.
Is this item
helpful? yes no
Previous votes Yes: 3 No: 0
|
|
Comments and alternative answers
 |
More info on starting Tomcat
Alex Chaffee PREMIUM, May 21, 2001
Why this works: the init sequence calls each file in /etc/rc.d/rc3.d/S* with the parameter "start" during system startup, and each file in rc3.d/K* with the parameter "stop" during system shutdown.
If you don't want to set TOMCAT_HOME inside tomcat.sh, then just make a small script inside /etc/rc.d/init.d/tomcat instead of a link. This will allow you to unpack a new version of Tomcat without having to edit the scripts again. E.g.:
#!/bin/sh
JAVA_HOME=/usr/lib/java; export JAVA_HOME
TOMCAT_HOME=/usr/local/tomcat; export TOMCAT_HOME
$TOMCAT_HOME/bin/tomcat.sh $*
Please see the original forum thread -- http://www.jguru.com/forums/view.jsp?EID=420073 -- for some more great information, including a script for SuSE.
See also
How can I start Tomcat as a daemon in Solaris?
Is this item
helpful? yes no
Previous votes Yes: 1 No: 0
|
|

|
 |
For shell scripting guru: init.d shell script???
Yuriy Dudko, Dec 6, 2001 [replies:2]
Does anybody have really good init.d shell script to start Tomcat as a daemon?
First, I want to start it before Apache
(using mod_jk). tomcat.sh does not wait
when the tomcat daemon is up and loads
httpd immediately.
Second, using above mentioned technic
on RedHat 7.1 I have all tomcat's
messages on my tty.
Therefore forced to start it by hand.
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
 |
Re: For shell scripting guru: init.d shell script???
Alessandro A. Garbagnati PREMIUM, Dec 6, 2001
Hi, I do not have any issue using tomcat.sh linked in the rc3.d directory of RedHat 7.1.
You should read Tomcat's documentation to fix some of your problem.
Tomcat does load the httpd server only if you leave the Tomcat's httpd server up in the server.xml configuration.
Tomcat's message are on the tty if you do not activate the logging to the file, as explained in the top of the server.xml file.
How to do these is covered either in the Jakarta-Tomcat's web site and in many FAQs. Do appropriate searches and you'll find the solution you're looking
for.
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
 |
 |
Re: For shell scripting guru: init.d shell script???
Karl Chu, Dec 21, 2001
I hope this is not too late, but I ran into the exact problem, and
I solved it by using the following segment of script in my startup script.
I use Slackware Linux (8.0), therefore, the script that I needed to change
is "/etc/rc.d/rc.M" rather than "init.d" or whatever, but it is essentially
the same idea.
The rc.tomcat4 and rc.httpd below are just two shell scripts
that I use to start up Tomcat and Apache. By the way, I am running
Tomcat 4.0.1 and Apache 2.0.28 Beta3, if that is important in any way.
# Start Tomcat:
# =============
TOMCAT_STARTING_LOCK=/tmp/tomcat_starting.lock
# Making sure the lock does not exist. In case we are not starting
# Tomcat, this makes sure starting of Apache is not hung up forever.
rm -f $TOMCAT_STARTING_LOCK
if [ -x /etc/rc.d/rc.tomcat4 ]; then
/bin/touch $TOMCAT_STARTING_LOCK
/etc/rc.d/rc.tomcat4 start
# While waiting for Tomcat to startup,
# we sleep for some time before removing the lock
/bin/sh -c "sleep 90; rm -f $TOMCAT_STARTING_LOCK" &
fi
# Start Web server:
# =================
if [ -x /etc/rc.d/rc.httpd ]; then
# While the "Tomcat lock" is still there, we wait. Once the lock is
# removed, we start Apache.
# We also push the whole thing into the background, so that we don't stall
# the startup of the rest of the stuff.
/bin/sh -c "while [ -e $TOMCAT_STARTING_LOCK ]; do sleep 5; done; . /etc/rc.d/rc.httpd start" &
fi
NOTICE the "&" above!
You may try to start Tomcat manually in the foregound by running
% $CATALINA_HOME/bin/catalina.sh run
and time how long does it take for Tomcat to finish starting up.
I have to admit that waiting for a hard-coded 90 seconds is not ideal,
but (in my case) I am not too concerned about how long it takes for the
server to start up.
Hope this helps.
Is this item
helpful? yes no
Previous votes Yes: 0 No: 0
|
|

|
|
|
 |
|