On 8 Jun 2003 at 21:59, Euan Guttridge wrote:

> slightly off subject : has anyone written a 'watchdog' for tomcat? Simply a
> process that checks if tomcat is alive every x seconds, if dead restarts
> tomcat. 

I was after this a couple of months back.  I found the solution in a list and 
accomodated it for 
tomcat.  Nothing briliant, nor is it the only way..  But its quick, short and sweet.  
This past 
week I did this "type" of heartbeat mechanism, currently for an app on BEA 7.0

Criteria for the Tomcat heartbeat:

1. Tomcat request
    a. No response no tomcat               -  Down
    b. A Response tomcat is up
           > If the requested servlet is not available  then Tomcat throws a 404 
status code

With this in mind:

create a heartbeat servlet  that calls hbURLCon = (HttpURLConnection)   
url.openConnection(); at 
some time interval.

StatusCode  =hbURLCon.getResponseCode();
if (statusCode > 400 & statusCode < 500) {
   // report Tomcat up
}  

You can get more sophisticated if you like.





Reply via email to