[CentOS] Starting tomcat on bootup

Wed May 3 03:58:59 UTC 2006
Todd Reed <treed at astate.edu>

That was it!  I didn't have the chkconfig: line...

Thanks.

-----Original Message-----
From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On Behalf
Of Nick
Sent: Tuesday, May 02, 2006 10:32 PM
To: CentOS mailing list
Subject: Re: [CentOS] Starting tomcat on bootup

Barry Brimer wrote:
>> I just installed Tomcat and when I run the chkconfig -add tomcat, it 
>> tells
>> me that tomcat does not support chkconfig.
>
> In order to support chkconfig, an init script must:
> 1.  Be located in /etc/rc.d/init.d (which /etc/init.d is a symlink to)
> 2.  Have a commented out line that contains "chkconfig: <default 
> runlevels for this service> <start priority> <stop priority>"
> 3.  Have a commented out line that contains "description: <a 
> description of the service>"
> 4.  Upon successful service startup, place a lock file in 
> /var/lock/subsys that matches the name of the service script.  Upon 
> successful service shutdown, the lockfile must be removed.
>
> It is worth noting that you must use "chkconfig --add <service name>" 
> in order to have the service script placed in the shutdown/restart 
> runlevels correctly.
>
> There are many great examples already provided by existing services.  
> They should be fairly straightforward reading.
Here's the init script we use, if it helps at all:

#!/bin/sh
#
# Tomcat Server
#
# chkconfig: 345 96 30
# description: Java servlet container

JAVA_HOME=/opt/jdk

PATH=${JAVA_HOME}/bin:${PATH}

TOMCAT_START=/opt/tomcat/bin/startup.sh

TOMCAT_STOP=/opt/tomcat/bin/shutdown.sh

export JAVA_HOME PATH

start()
{
        if [ -x ${TOMCAT_START} ]; then
                echo "Starting tomcat server..."
                ${TOMCAT_START} &
        else
                echo "Cannot start tomcat server"
        fi
}

stop()
{
        if [ -x ${TOMCAT_STOP} ]; then
                echo "Stopping tomcat server..."
                ${TOMCAT_STOP} &
        else
                echo "Cannot stop tomcat server"
        fi
}

restart()
{
        stop
        sleep 10
        start
}

status()
{
        echo "No status available for tomcat server"
}

case "$1" in
'start')
        start
        ;;
'stop')
        stop
        ;;
'restart')
        restart
        ;;
'status')
        status
        ;;
*)
        echo "Please supply an argument [start|stop|restart]"
esac

_______________________________________________
CentOS mailing list
CentOS at centos.org
http://lists.centos.org/mailman/listinfo/centos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3095 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20060502/87ac4a31/attachment-0004.bin>