Tomcat後台服務(開機啟動)Shell代碼,安裝過程請參照上一篇

來源:互聯網
上載者:User

# Open files number
ulimit -n 65535
#!/bin/bash
# chkconfig: 234 78 36
# description: Starts and stops Tomcat
##############################################################################
#
#   Copyright 2004 The Apache Software Foundation.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
##############################################################################
#
# Small shell script to show how to start/stop Tomcat using jsvc
# If you want to have Tomcat running on port 80 please modify the server.xml
# file:
#
#    <!-- Define a non-SSL HTTP/1.1 Connector on port 80 -->
#    <Connector className="org.apache.catalina.connector.http.HttpConnector"
#               port="80" minProcessors="5" maxProcessors="75"
#               enableLookups="true" redirectPort="8443"
#               acceptCount="10" debug="0" connectionTimeout="60000"/>
#
# That is for Tomcat-7.0.x (Apache Tomcat/7.0)
#
# Adapt the following lines to your configuration
JAVA_HOME=/var/tomcat/jdk1.7.0_05
CATALINA_HOME=/var/tomcat/tomcat
DAEMON_HOME=/var/tomcat/tomcat/bin/commons-daemon-1.0.10-native-src/unix
TOMCAT_USER=xz_lan
JAVA_OPTS="-Xms4096M -Xmx4096M -Xmn512M -Xss256K -XX:PermSize=256M -XX:MaxPermSize=256M -XX:-UseGCOverheadLimit -XX:SurvivorRatio=1 -Xnoclassgc -XX:+DisableExplicitGC -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:-CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128M -XX:CMSInitiatingOccupancyFraction=85 -XX:SoftRefLRUPolicyMSPerMB=0"

# for multi instances adapt those lines.
TMP_DIR=/var/tomcat/tomcat/temp
PID_FILE=/var/tomcat/tomcat/temp/jsvc.pid
CATALINA_BASE=/var/tomcat/tomcat

CATALINA_OPTS="-Djava.library.path=/var/tomcat/tomcat/bin/tomcat-native-1.1.24-src/jni/native/.libs"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/tomcat-juli.jar:\
$CATALINA_HOME/bin/bootstrap.jar

case "$1" in
  start)
    #
    # Start Tomcat
    #
    $DAEMON_HOME/jsvc \
    -user $TOMCAT_USER \
    -home $JAVA_HOME \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.io.tmpdir=$TMP_DIR \
    -wait 10 \
    -pidfile $PID_FILE \
    -outfile /var/tomcat/logs/catalina.out \
    -errfile /var/tomcat/logs/catalina.err \
    $JAVA_OPTS \
    $CATALINA_OPTS \
    -cp $CLASSPATH \
    org.apache.catalina.startup.Bootstrap
    #
    # To get a verbose JVM
    #-verbose \
    # To get a debug of jsvc.
    #-debug \
    chown -R xz_lan:xz_server /var/tomcat
    chown -R xz_lan:xz_server /var/tomcat/*
    exit $?
    ;;

  stop)
    #
    # Stop Tomcat
    #
    $DAEMON_HOME/jsvc \
    -stop \
    -pidfile $PID_FILE \
    org.apache.catalina.startup.Bootstrap
    exit $?
    ;;

  *)
    echo "Usage tomcat.sh start/stop"
    exit 1;;
esac

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.