Synopsis:
New property: shutdownWait if greater than zero. Then to the end of shutdown, a new daemon thread is created which sleeps for {shutdownWait} seconds. When (and if) the Thread wakes back up, it prints to System.out() then new message in LocalStrings.properties and then calls System.exit.
shutdownWait defaults to zero. If zero or neagtive, then it is ignored and the old behavior occurs. (Which is to do nothing extra)
This patch was from tomcat5.
If this is good enough to accept, I can later submit the patches for the admin app and mbeans-descriptors.xml.
Also attached is the JSP I used to ensure the server stayed running. Ignore the quality of the jsp - its just a test.
-Tim
Craig R. McClanahan wrote:
On Mon, 10 Feb 2003, Tim Funk wrote:Why is a kill done instead of a System.exit()?System.exit() is absolutely the wrong answer if Tomcat is embedded into a larger server-side application, rather than run separately in the usual way. At best, you would need to make this configurable somehow (with the default to *not* run System.exit()). Craig
Index: StandardServer.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardServer.java,v retrieving revision 1.12 diff -u -r1.12 StandardServer.java --- StandardServer.java 3 Feb 2003 23:05:48 -0000 1.12 +++ StandardServer.java 11 Feb 2003 14:33:10 -0000 @@ -321,6 +321,14 @@ /** + * On shutdown, wait this many seconds before forceful + * termination by calling System.exit(). Only used when + * greater than zero. + */ + private int shutdownWait = 0; + + + /** * The property change support for this component. */ protected PropertyChangeSupport support = new PropertyChangeSupport(this); @@ -330,6 +338,29 @@ /** + * Return the amount of time to wait on shutdown before calling System.exit() + */ + public int getShutdownWait() { + + return (this.shutdownWait); + + } + + + /** + * Set the amount of time to wait on shutdown before calling System.exit(). + * Forceful shutdown is in effect only when this is greater than zero. + * + * @param debug The new debugging detail level + */ + public void setShutdownWait(int shutdownWait) { + + this.shutdownWait = shutdownWait; + + } + + + /** * Return the debugging detail level. */ public int getDebug() { @@ -2328,6 +2359,29 @@ // Notify our interested LifecycleListeners lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null); + + /* Create a daemon thread to forceably exit if needed */ + if (shutdownWait>0) { + Thread killThread = new Thread() { + public void run() { + try{ + Thread.sleep(shutdownWait*1000); + } catch(InterruptedException e){ + } + /* + Since we got this far exit with status 1 + to signify we forcefully shutdown in case anyone is + keeping track. + + */ + + System.out.println(sm.getString("standardServer.stop.kill", "" + +shutdownWait)); + System.exit(1); + } + }; + killThread.setDaemon(true); + killThread.start(); + } } Index: LocalStrings.properties =================================================================== RCS file: /home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/LocalStrings.properties,v retrieving revision 1.5 diff -u -r1.5 LocalStrings.properties --- LocalStrings.properties 24 Jan 2003 23:47:45 -0000 1.5 +++ LocalStrings.properties 11 Feb 2003 14:33:10 -0000 @@ -125,6 +125,7 @@ standardServer.initialize.initialized=This server has already been initialized standardServer.start.connectors=At least one connector is not associated with any container standardServer.start.started=This server has already been started +standardServer.stop.kill=The shutdown process has taken longer than {0} seconds. +Calling System.exit(). standardServer.stop.notStarted=This server has not yet been started standardService.initialize.initialized=This service has already been initialized standardService.start.name=Starting service {0}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]