Disable Tomcat in the Linux environment, cannot be completely shut down via shutdown.sh-thread pool

Source: Internet
Author: User

Projects that have been tested on the most recent test environment cannot be completely closed through shutdown.sh.

There are two methods of temporary workaround:

First: by Ps-ef|grep Tomcat to see the Tomcat process using kill directly to kill the process.

Second: The basic principle is to log the process ID (PID) that starts Tomcat when Tomcat is started, forcing the process to kill when it is closed

1. Find Tomcat under Bin/catalina.sh file, vi to add something, mainly record Tomcat PID, as follows:

  

About the 125th line, add the following code

#设置CATALINA_PID (after addition)
If [-Z "$CATALINA _pid"]; Then
Catalina_pid= $PRGDIR/catalina_pid
Cat $CATALINA _pid
Fi

Save it.

2.vi into the shutdown.sh file, the last line below the red circle-force:

Save it.

However, the underlying problem has not been resolved at all. Find the problem idea: the Java-brought tool JPS or Linux comes with commands to find threads. Use JPS directly here. Find Thread

Then execute the jstack PID, an error like this

Method One: Starting with the Tomcat project, this is generally due to the existence of non-daemon threads in the project. So how to find the thread, please look at the following:

Using the jstack provided by the JDK can help us find: $JAVA _home/bin/jstack <pid>pid refers to the process ID, which can be viewed with ps-ef|grep Tomcat:

12126 is PID, continue to input jstack 12126 will see the following piles of things:

There is a bunch of thread pool error messages, which are copied from other friends on the Internet, but this pile of information is similar to mine. The thread cannot be stopped. Considering code again, it is found that code is closed in Tomcat without invoking the method of shutting down the thread pool. This needs to be closed manually, put the code

If you use spring's thread pool, it's best to add Destroy-method.

Finally, a thorough solution. Hope to help friends

Disable Tomcat in the Linux environment, cannot be completely shut down via shutdown.sh-thread pool

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.