Article From:https://www.cnblogs.com/lanweijava/p/9125134.html

  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
      CATALINA_PID=$PRGDIR/CATALINA_PID
      cat $CATALINA_PID
fi

Save it.

2.viEnter the shutdown.sh file in the last row as follows: red circle -force:

Save it.

 

  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:

 

Using jstack provided by JDK can help us find out:
$JAVA_HOME/bin/jstack  <pid>
pidRefers to the process ID, using PS -ef|grep Tomcat can be viewed:

 

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

 

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *