Recently, testing projects on the testing environment have never been completely shut down through shutdown.sh.
Two kinds of temporary solutions:
The first is to see the process of Tomcat through PS -ef|grep tomcat, and use kill to kill the process directly.
Second: the basic principle is to record the process of starting Tomcat (ID) (PID) when starting tomcat, and to kill the process when closing.
1.Find the bin/catalina.sh file under tomcat, VI add something, mainly recording Tomcat’s PID, as follows:
About 125th lines, add the following code
#Setting CATALINA_PID (after adding)
if [ -z “$CATALINA_PID” ]; then
2.viEnter the shutdown.sh file in the last row as follows: red circle -force:
But the fundamental problem has never been solved. Find the way of thinking: find the thread through Java’s own tool JPS or Linux. JPS is used directly here. Find the thread
Jstack PID is executed again, and there are errors like this
Method 1: starting from the project under tomcat, this is usually caused by the presence of non daemon threads in the project. So how to find the thread – changing thread, please look at the following:
12126That is, PID, continue to enter jstack 12126 will see the following pile of things:
There are also a bunch of thread pool error messages. The above screenshots are copied from other friends on the Internet, but this pile of information is almost the same as mine. The thread cannot stop. Considering code again, it is found that there is no way to close the thread pool when code closes Tomcat again. It needs to be closed manually and posted on the next generationcode
If you use the thread pool of spring, you’d better add destroy-method.
Finally, a thorough solution. Hope to be helpful to friends