Force Tomcat 6 for Windows

We use tomcat 6 to run Java based on activeMQ for our application. I recently learned how to implement a continuous deployment solution for components on the server side of this product.

What I want to do is our continuous integration server:
1. Throw the MSI installer to the virtual machine.
2. Stop Tomcat
3. Run the installer
4. Launch Tomcat
5. Verify that the server is running.

I can do all this except the Tomcat completion stage. The problem I am facing is that Tomcat does not always gracefully close it. Therefore, I need to make the server shut down. I am open to the weather or do not start Tomcat as a service. Does anyone have any info on how to close Tomcat 6 on Windows? I saw some documentation on using the -force , but this was patchy and aimed at Unix systems.

Any information you can provide will be greatly appreciated.


Edit: Tomcat may not be the only Java process running on a machine.

+4
source share
3 answers

If you are not running it as a service, and Tomcat is the only Java application, then you can use taskkill. Something like taskkill /F /IM java.exe should do the trick.

Note that forcibly killing a Tomcat process is safe for Tomcat. Any running applications may not be so forgiving, but since this is your application, you will know what is safe and what is not.

+4
source

Another answer (with taskkill) is good, but to get a PID search through the output of "sc queryex" for the name of the service you are interested in, then take its pid.

then it is taskkill / f / pid {pid} instead of just looking for java tasks.

I had to use a groovy script to do this, if you are well versed in powershell, you can get better results.

+1
source

The following command is executed to run tomcat on our Windows server on port 8080.

 @echo off FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO @ECHO Unable to stop Tomcat timely..Kill process %%P FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :8080') DO call TaskKill.exe /f /PID %%P 
0
source

Source: https://habr.com/ru/post/1412443/


All Articles