Java – embedded terminal and normal shutdown

I've dug into the jetty documentation and tried to figure out how to properly configure the embedded jetty to close gracefully, but I found it lacking

The example in the documentation uses setstopatshutdown (true) innocently However, there is no Javadoc or explanation for why As far as I know, the default value is set to false

In addition, setgracefulshutdown method changed to setstoptimeout() it sees, but this is also not recorded

So these are my questions:

>Why do you set or do not set stop when shutting down? > When does the override stop timeout (default is 30 seconds)? > What other matters should be considered when configuring jetty for normal shutdown?

Editor: after trial and error; It is found that if you want jetty to issue a shutdown event to any listener (such as spring's contextloaderlistener), you need setstopatshutdown (true)

Solution

The normal shutdown process requests each worker thread to close (i.e. complete the processing of the current request, then do not accept any new requests and exit) Then it waits a little (which can be configured by timeout), and if any threads remain, it will force them to kill This can happen because threads take a long time to process requests, for example, or because of deadlocks If the default value is maintained for 30 seconds, the application may take more than 30 seconds to exit Reducing the timeout value will give you faster shutdown time, but may sacrifice threads busy processing legitimate, active requests

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>