I've dug through the Jetty documentation trying to find out how to properly configure an embedded Jetty to shut down gracefully, but I found it lacking.
The examples in the documentation inconsequently use setStopAtShutdown(true)
. However, there is no JavaDoc or explanation why this should be done. As far as I can tell, the default value is set to false.
Additionally, the setGracefulShutdown()
method changed to setStopTimeout()
it seems, but this is not documented either.
So these are my questions:
Edit: After some trial and error; discovered that setStopAtShutdown(true) is required if you want to have Jetty signal a shutdown event to any listeners such as Spring's ContextLoaderListener.
The graceful shutdown procedure requests each worker thread to shut down (i.e. finish processing the current request, then don't accept any new requests and exit). It then waits for a bit (configurable via the timeout), and if any threads remain, it kills them forcefully. This can happen because the thread is taking a long time to process a request, for example, or because of a deadlock. If you keep the default value of 30 seconds, it might take a little more than 30 seconds for the application to exit. Reducing the value of the timeout will give you a faster shutdown time, but at the expense of potentially killing threads that were busy processing legitimate, active requests.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句