tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mr. Cristian Romanescu" <c.romane...@finsiel.ro>
Subject Re: Tomcat autostart on Linux
Date Fri, 25 Oct 2002 10:42:52 GMT
It depends on how it's installed, also Linux distro

If you have RedHat and istalled via rpm distro, you should have in 
/etc/init.d/ a script named tomcat4 that launches Tomcat @ statup.

  4 -rwxr-xr-x    1 root     root         3055 Mar  4  2002 tomcat4

(I'm not also a linux expert, but I suppose that should be marked 
executable.

also you can stop/start manually invoking
/etc/init.d/tomcat4 <start|restart>

Here's a quick'n paste solution....

----------------------
#!/bin/sh
#
# Startup script for Tomcat 4.0, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat 4.0 is the Apache Servlet Engine RI for Servlet 
2.3/JSP 1.2
# processname: tomcat
# pidfile: /var/run/tomcat4.pid
# config:  /etc/tomcat4/conf/tomcat4.conf
#
# Gomez Henri <hgomez@slib.fr>
# Keith Irwin <keith_irwin@non.hp.com>
# Nicolas Mailhot <nicolas.mailhot@one2team.com>
#
# version 1.02 - Removed initlog support
# version 1.03 - Removed config:
# version 1.04 - tomcat will start before httpd and stop after httpd
# version 1.05 - jdk hardcoded to link /usr/java/jdk and tomcat runs as 
"nobody"
# version 1.06 - split up into script and config file
# version 1.07 - Rework from Nicolas ideas
# version 1.08 - Fix work dir permission at start time, switch to use 
tomcat4
# version 1.09 - Fix pidfile and config tags
# version 1.10 - Fallback to su direct use on systems without 
Redhat/Mandrake init.d functions
# version 1.11 - Fix webapps dir permissions
#

# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi

# Get Tomcat config

TOMCAT_CFG="/etc/tomcat4/conf/tomcat4.conf"

[ -r "$TOMCAT_CFG" ] && . "${TOMCAT_CFG}"

# Path to the tomcat launch script (direct don't use wrapper)
TOMCAT_SCRIPT=/usr/bin/dtomcat4

# Tomcat name :)
TOMCAT_PROG=tomcat4

# if TOMCAT_USER is not set, use tomcat4 like Apache HTTP server
if [ -z "$TOMCAT_USER" ]; then
     TOMCAT_USER="tomcat4"
fi

# Since the daemon function will sandbox $tomcat
# no environment stuff should be defined here anymore.
# Please use the /etc/tomcat.conf file instead ; it will
# be read by the $tomcat script

RETVAL=0

# See how we were called.
start() {
     echo -n "Starting $TOMCAT_PROG: "

     chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME/logs
     chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME/work
     chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_TMPDIR
     chown -R $TOMCAT_USER:$TOMCAT_USER $CATALINA_HOME/webapps

     if [ -x /etc/rc.d/init.d/functions ]; then
         daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start
     else
         su - $TOMCAT_USER -c "$TOMCAT_SCRIPT start"
     fi

     RETVAL=$?
     echo
     [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat4
     return $RETVAL
}

stop() {
     echo -n "Stopping $TOMCAT_PROG: "
     if [ -x /etc/rc.d/init.d/functions ]; then
         daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
     else
         su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
     fi
     RETVAL=$?
     echo
     [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat4 /var/run/tomcat4.pid
}


# See how we were called.
case "$1" in
   start)
         start
         ;;
   stop)
         stop
         ;;
   restart)
         stop
# Ugly hack
# We should really make sure tomcat
# is stopped before leaving stop
         sleep 2
         start
         ;;
   condrestart)
         if [ -f /var/run/tomcat4.pid ] ; then
                 stop
                 start
         fi
         ;;
   *)
         echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}"
         exit 1
esac

exit
----------------------



neal wrote:

> Anyone know how to make Tomcat automatically startup when Linux is 
> rebooted?
>
> As you can probably tell I'm not a Linux expert.  :(
>
> Thanks.
> Neal
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:



-- 
Cristian D. Romanescu
alternative: cristian at qdrei.de
mobile     : +40745133096

--- "Pauca sed matura" - Gauss' motto ---


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message