SmartSolution
SmartSolution

Reputation: 2348

Shutdown tomcat using web application deployed in it

I've some doubt about tomcat operation which come across my webapp development:

  1. Is there any way to shutdown tomcat itself from the webapp deployed in it?
  2. Is tomcat is running all of its webapps/war inside one JVM or individual JVM or its configurable in some configuration file?
  3. Is it possible to increase the java heap size for particular webapp deployed inside tomcat?

Thanks a lot.

Upvotes: 7

Views: 2911

Answers (1)

Grzegorz Grzybek
Grzegorz Grzybek

Reputation: 6237

  1. Open TCP connection from some servlet and send "SHUTDOWN" to Tomcat's shutdown port (default: 8005).
  2. One Tomcat uses one JVM for all applications.
  3. No. Only for the entire JVM.

Here's code for point 1:

Socket clientSocket = new Socket("localhost", 8005);
clientSocket.getOutputStream().write("SHUTDOWN".getBytes());
clientSocket.getOutputStream().close();
clientSocket.close();

Upvotes: 7

Related Questions