In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
CentOS Tomcat startup service script how to write, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
1. Tomcat comes with jsvc. This tool starts 2 threads. If the application monopolizes the resources, it will cause the application to fail to start. This is the same as the daemon project in Apache Commons.
2. Java Service Wrapper
Referring to the script of nginx, I wrote a script for your reference:
The code is as follows:
#
#! / bin/bash
#
# chkconfig:-91 35
# description: Starts and stops tomcat
CATALINA_HOME=/data/site/tomcat-8085
PID_FILE=/var/run/tomcat8085.pid
JAVA_HOME=/usr/java/default
JAVA_OPTS= "- server-Xms512m-Xmx1024m"
CATALINA_BASE=$CATALINA_HOME
CATALINA_OPTS= "- Djava.library.path=$CATALINA_HOME/bin"
CLASSPATH=\
$JAVA_HOME/lib/tools.jar:\
$CATALINA_HOME/bin/commons-daemon.jar:\
$CATALINA_HOME/bin/bootstrap.jar
RETVAL=0
# Source function library.
. / etc/rc.d/init.d/functions
# Source networking configuration.
. / etc/sysconfig/network
# Check that networking is up.
[${NETWORKING} = "no"] & & exit 0
# Start daemons functions.
Start () {
#
# Start Tomcat
#
If [- e $PID_FILE]; then
Echo "$PID_FILE already running...."
Exit 1
Fi
Echo-n $"Starting $PID_FILE:"
Nohup $JAVA_HOME/bin/java\
-Dcatalina.home=$CATALINA_HOME\
-Dcatalina.base=$CATALINA_BASE\
-Djava.io.tmpdir=$TMP_DIR\
$CATALINA_OPTS\
-cp $CLASSPATH\
$JAVA_OPTS\
Org.apache.catalina.startup.Bootstrap start > $CATALINA_HOME/logs/catalina.out &
RETVAL=$?
Echo
[$RETVAL = 0] & & touch $PID_FILE
Return $RETVAL
}
# Stop daemons functions.
Stop () {
#
# Stop Tomcat
#
Echo-n $"Stopping $PID_FILE:"
Nohup $JAVA_HOME/bin/java\
-Dcatalina.home=$CATALINA_HOME\
-Dcatalina.base=$CATALINA_BASE\
-Djava.io.tmpdir=$TMP_DIR\
$CATALINA_OPTS\
-cp $CLASSPATH\
Org.apache.catalina.startup.Bootstrap stop > $CATALINA_HOME/logs/catalina.out &
RETVAL=$?
Echo
[$RETVAL = 0] & & rm-f $PID_FILE
Return $RETVAL
}
# See how we were called.
Case "$1" in
Start)
Start
Stop)
Stop
Restart)
Stop
Start
*)
Echo $"Usage: $prog {start | stop | restart}"
Exit 1
Esac
Exit $RETVAL
Installation steps
1. # vi tomcatd enter the above script
2. # chmod + x tomcatd is configured with execution permission
3. # copy cp tomcatd / etc/init.d to the startup directory
4. # chkconfig-add tomcatd
5. # chkconfig tomcatd on
6. # service tomcatd start start
7. # service tomcatd stop stop
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.