• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can shutdown tomcat from my webapp?

 
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all
we use tomcat as our servlet container , after N defined number of exceptions
i like to shotdown tomcat process how can it be done from the webapp?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat is not designed to be shut down from a web app.
There are other, more graceful ways to stop traffic to your site.

If you have a front controller, you could have it throw an UnavailableException.

If not, you could write filter that checks for a context scope variable and forwards to a particular JSP with a friendly error message letting the user know that the server is down for maintenance or something if it finds it.
[ August 14, 2007: Message edited by: Ben Souther ]
 
ben josh
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well my case here that im using tomcat as part of mush bigger enterprise application.
And it not enough to sop the application in some form. I need to shutdown the tomcat process
So all the Big Brother / Guard application will inform there is problem in the web application

There must be some kind of hack..
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Meir Yan:
There must be some kind of hack..


There are always hacks.

If you're running on a unix system, Tomcat is started and stopped with shell scripts in the bin directory.
This is also the case with the batch scripts if you're on a Windows and have installed Tomcat with the ".zip" distribution.
You could write a servlet that uses Runtime.exec to call those scripts.

If you're running Tomcat as a Windows service, you can use the net stop <service-name> to stop it.

A real crude way of stopping it (REAL crude) would be to call System.exec(1) from within your Java code. This shuts down the entire JVM in which Tomcat is running.

If Tomcat is running under a security manager, none of the above will probably be allowed without modifying the policy.


I still think there should be a better way to let the parent app know that there is a problem with the web app. It can't detect a 500 error code coming from Tomcat?
[ August 15, 2007: Message edited by: Ben Souther ]
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic