极乐门资源网 Design By www.ioogu.com
1. tomcat 自带的 jsvc, 这个工具会启动2个线程,如果应用对资源独占,会造成应用启动不了,这个和Apache Commons 里的 daemon 项目是一样的。
2. Java Service Wrapper ,
参考nginx的脚本,自己写了一个脚本,供大家参考:
复制代码代码如下:
#
#!/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
安装步骤
1. #vi tomcatd 输入以上脚本
2. #chmod +x tomcatd 设置有执行权限
3. #cp tomcatd /etc/init.d 复制到启动目录
4. #chkconfig --add tomcatd
5. #chkconfig tomcatd on
6. #service tomcatd start 启动
7. #service tomcatd stop 停止
2. Java Service Wrapper ,
参考nginx的脚本,自己写了一个脚本,供大家参考:
复制代码代码如下:
#
#!/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
安装步骤
1. #vi tomcatd 输入以上脚本
2. #chmod +x tomcatd 设置有执行权限
3. #cp tomcatd /etc/init.d 复制到启动目录
4. #chkconfig --add tomcatd
5. #chkconfig tomcatd on
6. #service tomcatd start 启动
7. #service tomcatd stop 停止
标签:
CentOS,Tomcat
极乐门资源网 Design By www.ioogu.com
极乐门资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
极乐门资源网 Design By www.ioogu.com
暂无CentOS Tomcat 的启动服务脚本的评论...
更新日志
2025年01月10日
2025年01月10日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]