Tomcat 7没有关闭,进程一直在运行?

时间:2014-07-23 07:09:37

标签: java tomcat

我使用

启动了tomcat 7
cd /opt/tomcat7/bin    
$/opt/tomcat7/bin ./startup.sh

显示进程正在运行

root     23206  130  3.4 1323956 572880 pts/2  Sl   07:58   1:05 /usr/bin/java -Djava.util.logging.config.file=/opt/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dspring.profiles.active=mongo1,maxListenersAllowed -DST_SERVER=mongo1 -Djava.endorsed.dirs=/opt/tomcat7/endorsed -classpath /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat7 -Dcatalina.home=/opt/tomcat7 -Djava.io.tmpdir=/opt/tomcat7/temp org.apache.catalina.startup.Bootstrap start

如果我使用

关闭它
$/opt/tomcat7/bin ./shutdown.sh

它给出了这条消息

Using CATALINA_BASE:   /opt/tomcat7
Using CATALINA_HOME:   /opt/tomcat7
Using CATALINA_TMPDIR: /opt/tomcat7/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/tomcat7/bin/bootstrap.jar:/opt/tomcat7/bin/tomcat-juli.jar

但是如果我检查上面的过程,它仍会显示它正在运行。 Tomcat没有关闭。我也尝试使用root用户,但仍然没有成功。

Manully我可以杀死进程,但我想创建部署脚本,所以想要使用shutdown.sh和startup.sh

如果我尝试使用

,也会发生同样的情况
/opt/tomcat7/bin/catalina.sh start
/opt/tomcat7/bin/catalina.sh stop

日志

Jul 23, 2014 8:26:17 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/i386:/lib:/usr/lib
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 361 ms
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 23, 2014 8:26:18 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/docs
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/ROOT
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/examples
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/host-manager
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/tomcat7/webapps/target
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:18 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 862 ms
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardServer await
INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8081"]
Jul 23, 2014 8:26:42 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

4 个答案:

答案 0 :(得分:10)

您可以通过PID强制关闭。

修改

..tomcat/bin/catalina.sh

并设置

CATALINA_PID=path

变量到本地路径。

  

CATALINA_PID

     

(可选)应该包含pid的文件的路径   catalina启动java进程,当启动(fork)时使用

然后您可以使用-force标志

关闭Tomcat
../tomcat/bin/shutdown.sh -force

如果脚本无法停止,Tomcat通常会使用kill来通过PID停止进程。

<强>更新

根据Joshua Taylor的评论,存储运行tomcat的其他变量的推荐方法是setenv。*脚本。

看一下(3.4)使用&#34; setenv&#34;运行docs的tomcat中的脚本(可选,推荐)部分

https://tomcat.apache.org/tomcat-7.0-doc/RUNNING.txt

答案 1 :(得分:1)

如果您在Windows中并使用便携式tomcat,则可以使用nircmd程序工具,并通过标题控制台窗口关闭,而不是通过PID停止。 下载此工具后,只需执行以下操作:

nircmd.exe win close title "Tomcat"

答案 2 :(得分:1)

由于验证机制错误,我曾经遇到过运行无限重定向循环的页面的不幸。

它最终放慢了整个服务器的速度,但也使我无法优雅地关闭它。最后,我不得不像vzamanillo描述的那样使用蛮力。

关键是在服务器的流程中可能会运行一些可能无法正常完成的过程。

答案 3 :(得分:0)

你设置了关闭端口吗? (在 /etc/tomcat9/conf/server.xml )

<Server  port="9005"  shutdown="SHUTDOWN">