how to know if tomcat is completely started

2010-02-11 Thread Jan Van Besien

Hi all,

I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

We are using the tanuki service wrapper to run tomcat as a linux 
service, more or less as described in [1].


We also have a monitoring mechanism which checks the health of the 
running tomcat with all the applications deployed into it by making 
certain well choosen http requests that test some core functionality of 
our applications. If some of this fails, a system is in place to have 
another redundant server (with another tomcat) take over.


Now the problem is that we only want the monitoring mechanism to start 
monitoring after tomcat is completely started (successful or not). So I 
would like to know what my options are to ask a running tomcat if it 
has more startup/deployment work to do, or if it is finished.


The log files contain things like INFO: Server startup in 39188 ms, so 
clearly tomcat knows this information. I could ofcourse parse the log 
files, but I would prefer a more robust mechanism. Maybe a java API, or 
JMX or something like that?


Thanks in advance,
Jan Van Besien

[1] 
http://wrapper.tanukisoftware.org/doc/english/integrate-start-stop-nix.html


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: how to know if tomcat is completely started

2010-02-11 Thread Pid

On 11/02/2010 11:15, Jan Van Besien wrote:

Hi all,

I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

We are using the tanuki service wrapper to run tomcat as a linux
service, more or less as described in [1].

We also have a monitoring mechanism which checks the health of the
running tomcat with all the applications deployed into it by making
certain well choosen http requests that test some core functionality of
our applications. If some of this fails, a system is in place to have
another redundant server (with another tomcat) take over.

Now the problem is that we only want the monitoring mechanism to start
monitoring after tomcat is completely started (successful or not). So I
would like to know what my options are to ask a running tomcat if it
has more startup/deployment work to do, or if it is finished.

The log files contain things like INFO: Server startup in 39188 ms, so
clearly tomcat knows this information. I could ofcourse parse the log
files, but I would prefer a more robust mechanism. Maybe a java API, or
JMX or something like that?


How do you define completely started?  E.g. The server might start but 
the applications not start.


Apart from JMX, there a number of things you can do within the server 
and each application that could lead to a notification.  Implement a 
ServletContextListener for an application, or a LifecycleListener for 
the server.



p


Thanks in advance,
Jan Van Besien

[1]
http://wrapper.tanukisoftware.org/doc/english/integrate-start-stop-nix.html

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: how to know if tomcat is completely started

2010-02-11 Thread Jan Van Besien

Pid wrote:

On 11/02/2010 11:15, Jan Van Besien wrote:

Hi all,

I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

We are using the tanuki service wrapper to run tomcat as a linux
service, more or less as described in [1].

We also have a monitoring mechanism which checks the health of the
running tomcat with all the applications deployed into it by making
certain well choosen http requests that test some core functionality of
our applications. If some of this fails, a system is in place to have
another redundant server (with another tomcat) take over.

Now the problem is that we only want the monitoring mechanism to start
monitoring after tomcat is completely started (successful or not). So I
would like to know what my options are to ask a running tomcat if it
has more startup/deployment work to do, or if it is finished.

The log files contain things like INFO: Server startup in 39188 ms, so
clearly tomcat knows this information. I could ofcourse parse the log
files, but I would prefer a more robust mechanism. Maybe a java API, or
JMX or something like that?


How do you define completely started?  E.g. The server might start but 
the applications not start.


I agree this is a subtile question, but whatever makes tomcat decide to 
log Server startup in xxx ms is good for me. Note that it also logs 
this if one of the deployments failed.


Apart from JMX, there a number of things you can do within the server 
and each application that could lead to a notification.  Implement a 
ServletContextListener for an application, or a LifecycleListener for 
the server.


I don't want anything in my applications per se, because when tomcat 
fails to deploy one of my applications (for whatever reason), I still 
want to know that tomcat is finished trying to deploy my applications.


Kind regards
Jan

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: how to know if tomcat is completely started

2010-02-11 Thread Peter Crowther
In that case, you want a LifecycleListener
(http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/LifecycleListener.html)
looking for the AFTER_START event.  You can then write code in the
listener to do something unambiguous when the event triggers - I'd
write a file somewhere, but I'm old-fashioned like that.

Configuration is performed by adding a Listener element to your
server.xml - see
http://tomcat.apache.org/tomcat-6.0-doc/config/listeners.html for some
of the docs, though I'm not aware of a tutorial anywhere that shows
how to implement and add one.  You'll want to nest yours inside the
Server element, I think.

- Peter

On 11 February 2010 12:15, Jan Van Besien janvanbes...@gmail.com wrote:
 Pid wrote:

 On 11/02/2010 11:15, Jan Van Besien wrote:

 Hi all,

 I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

 We are using the tanuki service wrapper to run tomcat as a linux
 service, more or less as described in [1].

 We also have a monitoring mechanism which checks the health of the
 running tomcat with all the applications deployed into it by making
 certain well choosen http requests that test some core functionality of
 our applications. If some of this fails, a system is in place to have
 another redundant server (with another tomcat) take over.

 Now the problem is that we only want the monitoring mechanism to start
 monitoring after tomcat is completely started (successful or not). So I
 would like to know what my options are to ask a running tomcat if it
 has more startup/deployment work to do, or if it is finished.

 The log files contain things like INFO: Server startup in 39188 ms, so
 clearly tomcat knows this information. I could ofcourse parse the log
 files, but I would prefer a more robust mechanism. Maybe a java API, or
 JMX or something like that?

 How do you define completely started?  E.g. The server might start but
 the applications not start.

 I agree this is a subtile question, but whatever makes tomcat decide to log
 Server startup in xxx ms is good for me. Note that it also logs this if
 one of the deployments failed.

 Apart from JMX, there a number of things you can do within the server and
 each application that could lead to a notification.  Implement a
 ServletContextListener for an application, or a LifecycleListener for the
 server.

 I don't want anything in my applications per se, because when tomcat fails
 to deploy one of my applications (for whatever reason), I still want to know
 that tomcat is finished trying to deploy my applications.

 Kind regards
 Jan

 -
 To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: users-h...@tomcat.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: how to know if tomcat is completely started

2010-02-11 Thread Ken Bowen
Using a Tomcat Lifecycle listener  (.../catalina/Lifecycle.html)  
sounds like exactly what you want.
This from http://www.atomikos.com/Documentation/Tomcat55Integration33   
illustrates illustrates the use:


public class AtomikosLifecycleListener implements LifecycleListener {
   private static Log log =  
LogFactory.getLog(AtomikosLifecycleListener.class);


   private UserTransactionManager utm;

   public void lifecycleEvent(LifecycleEvent event) {
  if (Lifecycle.START_EVENT.equals(event.getType())) {
 if (utm == null) {
log.info(starting Atomikos Transaction Manager  +  
Configuration.VERSION);

utm = new UserTransactionManager();
 }
  }
  else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
 if (utm != null) {
log.info(shutting down Atomikos Transaction Manager);
utm.close();
 }
  }
   }
}

Hope this helps.

On Feb 11, 2010, at 7:15 AM, Jan Van Besien wrote:


Pid wrote:

On 11/02/2010 11:15, Jan Van Besien wrote:

Hi all,

I'm using tomcat-6.0.18 with java-1.6.0-18 on ubuntu-9.10.

We are using the tanuki service wrapper to run tomcat as a linux
service, more or less as described in [1].

We also have a monitoring mechanism which checks the health of the
running tomcat with all the applications deployed into it by making
certain well choosen http requests that test some core  
functionality of
our applications. If some of this fails, a system is in place to  
have

another redundant server (with another tomcat) take over.

Now the problem is that we only want the monitoring mechanism to  
start
monitoring after tomcat is completely started (successful or not).  
So I
would like to know what my options are to ask a running tomcat  
if it

has more startup/deployment work to do, or if it is finished.

The log files contain things like INFO: Server startup in 39188  
ms, so
clearly tomcat knows this information. I could ofcourse parse the  
log
files, but I would prefer a more robust mechanism. Maybe a java  
API, or

JMX or something like that?
How do you define completely started?  E.g. The server might  
start but the applications not start.


I agree this is a subtile question, but whatever makes tomcat decide  
to log Server startup in xxx ms is good for me. Note that it also  
logs this if one of the deployments failed.


Apart from JMX, there a number of things you can do within the  
server and each application that could lead to a notification.   
Implement a ServletContextListener for an application, or a  
LifecycleListener for the server.


I don't want anything in my applications per se, because when tomcat  
fails to deploy one of my applications (for whatever reason), I  
still want to know that tomcat is finished trying to deploy my  
applications.


Kind regards
Jan

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org