I just installed Tomcat and when I run the chkconfig -add tomcat, it tells me that tomcat does not support chkconfig.
Suggestions?
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.
Best of luck, Barry
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:
- Be located in /etc/rc.d/init.d (which /etc/init.d is a symlink to)
- 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
Nick wrote:
Here's the init script we use, if it helps at all:
In enhancement to Nick's script, I've cooked up some tricks you can add to it to allow keeping your server.xml and java options in another location (i.e. version control). Using Nick's script layout:
server.xml inclusion:
XMFILE=/some/path/to/server.xml ${TOMCAT_START} -config $XMFILE &
catalina options:
CATALINA_OPTS="" while read option && [[ "$option" != end ]] do CATALINA_OPTS="$CATALINA_OPTS $option" done < "/some/path/to/catalina.properties" export CATALINA_OPTS
example catalina.properties:
-Djava.library.path=/opt/lib -Djmagick.systemclassloader=no -Djava.awt.headless=true
It's also handy to change the default jdk parameters for more efficient behaviour:
JAVA_OPTS="-server -Xms512m -Xmx512m" export JAVA_OPTS
If your want to get some good debugging (i.e. looking for a memory leak somewhere that's not getting garbage collected), use something like this:
JAVA_OPTS="-server -Xms512m -Xmx512m -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:/var/tmp/java_gc.log"
hth, -te