Based on the CatalinaEventHandler.stopContext(Context)
source code, there is no easy way to speedup the web application shutdown.
However, I used a workaround: I replaced the 5000
constant value (line 287) by a value from the system properties, compiled and repackaged the jboss-as/server/myServer/deploy/mod-cluster.sar/mod-cluster-1.0.10.GA_CP02.jar
(and removed the signing information from the JAR in MANIFEST.MF
and other .SF
file):
// get the timeout
long timeout = 5000; // the default timeout
String propName = "org.jboss.modcluster.CatalinaEventHandler.stopContext.timeout";
String timeoutStr = System.getProperty(propName);
if (timeoutStr!=null) {
try {
timeout = Long.parseLong(timeoutStr);
} catch (NumberFormatException e) {
log.warn("could not parse "+propName+" : "+e.toString());
}
}
// wait for requests being processed
try {
thr.sleep(timeout);
} catch(Exception ex) {
}
Then I start the server using -Dorg.jboss.modcluster.CatalinaEventHandler.stopContext.timeout=50
and my web applications do their shutdown very fast since the wait period is only 50 ms.