Semantic Essential >>
<< 骑自行车的感想
Install Tomcat as daemon under Linux

Author Zhou Renjian Create@ 2004-11-30 10:48
whizz Note icon
tomcat script:
#       This is the init script for starting up the
#               Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

tomcat=/usr/local/jakarta-tomcat
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/local/java

start(){
        echo -n $"Starting Tomcat service: "
        # Change to tomcat user to start server. Don't run as root.
        #daemon -c
        su -l zhourj $startup
        RETVAL=$?
        echo
}

stop(){
        echo -n $"Stopping Tomcat service: "
        su -l zhourj $shutdown
        RETVAL=$?
        echo
}
stop(){
        echo -n $"Stopping Tomcat service: "
        su -l zhourj $shutdown
        RETVAL=$?
        echo
}

restart(){
    stop
    start
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        # This doesn't work ;)
        status tomcat
        ;;
  restart)
        restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit 0

1. Modify the file "tomcat", change "su -l zhourj" to the new username.
2. Copy the script file "tomcat" to /etc/init.d/
3. Add the line "export JAVA_HOME=/usr/local/java" to files "startup.sh" and "shutdown.sh"

本记录所在类别:
本记录相关记录: