Tomcat 进程意外退出-tomcat stopInternal

最近开发环境的tomcat总是莫名其妙的挂了。

Aug 04, 2018 10:50:04 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-18080"]
Aug 04, 2018 10:50:04 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-58080"]
Aug 04, 2018 10:50:04 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
20180804:10:50:04.547 [localhost-startStop-2] [org.springframework.context.support.AbstractApplicationContext-982] INFO Closing WebApplicationContext for namespace 'optimus-servlet': startup date [Sat Aug 04 10:07:59 CST 2018]; parent: Root WebApplicationContext
Aug 04, 2018 10:50:05 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Aug 04, 2018 10:50:05 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Aug 04, 2018 10:50:05 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

Aug 04, 2018 10:50:05 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-18080"]
Aug 04, 2018 10:50:05 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-58080"]
Aug 04, 2018 10:50:05 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-18080"]
Aug 04, 2018 10:50:05 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-58080"]

Google搜索引擎 找到答案:

转载自并发编程网 – ifeve.com  链接地址: Tomcat进程意外退出的问题分析

另外见:

tomcat server组件监听shutdown命令关闭服务器之源码分析

https://blog.csdn.net/joenqc/article/details/75212775

启动tomcat的脚本:

按照并发编程网大神的提示:加上

#使用监视模式
set -m

完美解决问题。

#!/usr/bin/env sh
# 参数1 分支 参数2 配置项
#使用监视模式
set -m
p1=18080;
p2=$1;
p3=$2;
if [ $# -lt 1 ]; then
 p2=develop
fi
if [ $# -lt 2 ]; then
 p3=xjf221
fi
sysname=test
cd `dirname $0`
cur_dir_temp=`pwd`;
cur_dir=$(dirname ${cur_dir_temp})
echo ${cur_dir}

git reset --hard
git clean -xdf
git checkout ${p2};
git pull;

cd ${cur_dir}

#配置Tomcat
cd `pwd`/script && sh setup_tomcat.sh ${sysname} ${p1};
cd ${cur_dir}

mvn clean install -DskipTests

ps auxwww | grep java | grep ${p1} | grep ${sysname} | awk '{print $2}' | xargs kill -9 2>/dev/null;
~/tomcat/tomcat_${sysname}_${p1}/bin/shutdown.sh ;
rm -rf ~/tomcat/tomcat_${sysname}_${p1}/webapps/ROOT.war;
rm -rf ~/tomcat/tomcat_${sysname}_${p1}/webapps/ROOT;
unzip ${cur_dir}/target/ROOT.war -d ~/tomcat/tomcat_${sysname}_${p1}/webapps/ROOT;
rm -rf catalina.pid 2>/dev/null;
~/tomcat/tomcat_${sysname}_${p1}/bin/startup.sh;

cd ~/tomcat/tomcat_${sysname}_${p1}/logs
tailf catalina.out