Tomcat Background Service (startup) Shell code. For the installation process, refer to the previous article

Source: Internet
Author: 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 before t in compliance with the License.
# You may obtain a copy of the License
#
# 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" type = "codeph" text = "codeph"/>
#
# 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
DAEMON_HOME =/var/tomcat/bin/commons-daemon-1.0.10-native-src/unix
TOMCAT_USER = xz_lan
JAVA_OPTS = "-Xms4096M-Xmx4096M-Xmn512M-Xss256K-XX: PermSize = 256 M-XX: MaxPermSize = 256 M-XX:-UseGCOverheadLimit-XX: export vorratio = 1-Xnoclassgc-XX: + DisableExplicitGC-XX: + UseParNewGC-XX: + UseConcMarkSweepGC-XX: + export-XX: bytes = 0-XX: + CMSClassUnloadingEnabled-XX: -CMSParallelRemarkEnabled-XX: LargePageSizeInBytes = 128 M-XX: CMSInitiatingOccupancyFraction = 85-XX: SoftRefLRUPolicyMSPerMB = 0"

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

CATALINA_OPTS = "-Djava. library. path =/var/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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.