Debian - Problems autostart Tomcat 4.1.30 on boot

Kernels & Hardware, configuring network, installing services

Debian - Problems autostart Tomcat 4.1.30 on boot

Postby KaminariJ » 2004-10-12 09:28

I am trying to autostart Tomcat webserver 4.1.30 on boottime (Debian Woody distro), but it just won't start? It does start when I start it manually...

I have created a bootscript 'tomcat4' in /etc/init.d:

Code: Select all
               
# Setup JAVA_HOME
PATH=/usr/java/j2sdk1.4.2_05/bin:$PATH:$HOME/bin:./
export PATH
export JAVA_HOME=/usr/java/j2sdk1.4.2_05
export CLASSPATH=/usr/java/j2sdk1.4.2_05/jdk/lib/tools.jar:/usr/java/j2sdk1.4.2_05/jre/lib/rt.jar:./

# Start Tomcat4
sh /var/tomcat4/bin/startup.sh start


Next, I added the symlinks to rc?.d:

Code: Select all
update-rc.d tomcat4 start 20 2 3 4 5  . stop 20 0 1 6 .


When I reboot, Tomcat doesn't autostart? Can anybody tell me what mistake I make? Do I forget something? Thanks for any help![/code]
KaminariJ
 

Postby wiktorw » 2005-04-28 17:05

Do you still need to start Tomcat upon boot?
I've crafted a working script so maybe I can help. But do you still need that?
Experience shows that you can never have enough experience.
If someone solves a problem for you, say thanks... and put [SOLVED] in the title!
User avatar
wiktorw
 
Posts: 10
Joined: 2005-04-28 10:56

Postby wiktorw » 2005-05-05 19:59

I thought that I'll post my scripts anyway. But please see notes (*)

/etc/default/java
Code: Select all
# Default path settings for Java Runtime Environment and
# Java Software Development Kit.
# This file can be sourced by any script depending on Java.

# JDK default path
JAVA_HOME=/opt/j2sdk1.4.2_08

# JDK alternative path
JDK_HOME=/opt/j2sdk1.4.2_08

# Update PATH so java and javac can be found
PATH=${JAVA_HOME}/bin:${JDK_HOME}/jre/bin:${PATH}


/etc/default/tomcat
Code: Select all
# Default settings for Jakarta Tomcat server.
# This file is sourced by /etc/init.d/tomcat

# Location of Tomcat installation
CATALINA_HOME=/opt/jakarta-tomcat-5.0.28

# Location of Tomcat public root directory
CATALINA_BASE=/home/services/tomcat

# Location of running process id file
CATALINA_PID=/var/run/tomcat.pid


/etc/init.d/tomcat
Code: Select all
#!/sbin/sh
#
# Manage Tomcat server startup and shutdown

if [ -f /etc/default/java ]; then
    . /etc/default/java
fi

# If configuration file is missing, just exit
if [ ! -f /etc/default/tomcat ]; then
    exit 0
fi

. /etc/default/tomcat

export JAVA_HOME CATALINA_HOME CATALINA_BASE CATALINA_PID

case "$1" in
    start)
        echo "Starting Tomcat..."
        if [ -x $CATALINA_HOME/bin/startup.sh ] ; then
            $CATALINA_HOME/bin/startup.sh
        fi
        echo "done."
        ;;
    stop)
        if [ ! -f $CATALINA_PID ] ; then
            echo "Tomcat is not running, not stopping it."
        else
            echo "Stopping Tomcat..."
            if [ -x $CATALINA_HOME/bin/shutdown.sh ]; then
                $CATALINA_HOME/bin/shutdown.sh -force
                rm -f $CATALINA_PID
            fi
            echo "done."
        fi
        ;;
    restart)
        echo "Restarting Tomcat..."
        if [ -f $CATALINA_PID ]; then
            if [ -x $CATALINA_HOME/bin/shutdown.sh ]; then
                $CATALINA_HOME/bin/shutdown.sh -force
                rm -f $CATALINA_PID
            fi
            echo
        fi
        if [ -x $CATALINA_HOME/bin/startup.sh ] ; then
            $CATALINA_HOME/bin/startup.sh
        fi
        echo "done."
        ;;
    *)
        echo "Usage: $0 { start | stop | restart }"
        exit 1
        ;;
esac

exit 0


(*) Notes:
1) I always install JDK, not JRE. The JDK I used is 1.4.2_08 installed in /opt.

2) I always separate Tomcat binaries from www root. I place the latter in /home/services/tomcat. Essentially, it is a copy of most directories of Tomcat installation from /opt/jakarta-tomcat-<version>.
If you have no idea what directories to copy there, then copy all directories EXCLUDING /opt/jakarta-tomcat-<version>/bin. Then you can change configuration in conf, install applications in webapps, etc., but you still have original copy of files in /opt.

3) I put start symlink for tomcat in /etc/rc3.d and kill symlinks in /etc/rc1.d and /etc/rc0.d with number 99.

4) Even though after starting the script you get back to prompt quite quickly, Tomcat itself starts in about 10 seconds (not counting applications). So, if you need to restart it sometimes, give it a little time before sending requests or refreshing a browser.

I used the above configuration for some time in production environment with good results.
So at least I know that this setup works for me.
Experience shows that you can never have enough experience.
If someone solves a problem for you, say thanks... and put [SOLVED] in the title!
User avatar
wiktorw
 
Posts: 10
Joined: 2005-04-28 10:56


Return to System configuration

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable