Wait until tomcat finishes starting up Wait until tomcat finishes starting up linux linux

Wait until tomcat finishes starting up


There are probably several ways to do this. The trick we use is:

#!/bin/bashuntil [ "`curl --silent --show-error --connect-timeout 1 -I http://localhost:8080 | grep 'Coyote'`" != "" ];do  echo --- sleeping for 10 seconds  sleep 10doneecho Tomcat is ready!

Hope this helps!


It's not hard to implement programaticaly. You can implement org.apache.catalina.LifecycleListener and then you'll have

public void lifecycleEvent(LifecycleEvent lifecycleEvent) {            if(lifecycleEvent.getType().equals(Lifecycle.START_EVENT))            //do what you want            }       }

in web.xml :

<Context path="/examples" ...>...<Listener className="com.mycompany.mypackage.MyListener" ... >...</Context>

Please notice that some things could differ between 6-9 Tomcats.


Are you still looking for an answer? It depends on your definition of started. If your definition of started is "Now its safe to stop" then you might want to verify if port 8005 is listening.