Embedded Jetty and graceful shutdown

Odinodin

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:

  1. Why would you set or not set stop at shutdown?
  2. When would you override the stop timeout (defaults to 30 seconds)?
  3. What other things should be taken into consideration when configuring Jetty for graceful shutdown?

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.

jbyler

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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

REST resources with embedded Jetty server

来自分类Dev

Jetty Embedded,泽西岛2,焊缝

来自分类Dev

响应标题太大-Jetty Embedded版本9

来自分类Dev

Jersey Jetty Embedded无法读取路径注释,错误404

来自分类Dev

Jetty Embedded:使用 CORS + 基本身份验证 (ConstraintSecurityHandler)

来自分类Dev

具有Maven的Embedded Jetty示例无法重新启动:地址已在使用中

来自分类Dev

要求过滤器在Embedded Jetty的Jersey 2中不起作用

来自分类Dev

Maven Jetty Embedded(Fat jar)-Jar中缺少src / main / webapp

来自分类Dev

Jetty IncludeCipherSuites

来自分类Dev

git graceful rebase / complete合并到分支

来自分类Dev

npm WARN不推荐使用[email protected]:graceful-fs版本3

来自分类Dev

Using Jetty's proxy in standalone Jetty application

来自分类Dev

与以下Jersey / Jetty代码等效的CXF / Jetty

来自分类Dev

让Run-Jetty-Run使用最新的Jetty

来自分类Dev

shutdown()和shutdownNow()的混合

来自分类Dev

"Channel shutdown: connection error"

来自分类Dev

不懂ExecutorService#shutdown

来自分类Dev

运行Grunt任务时出现graceful-fs警告

来自分类Dev

在Windows上运行npm命令时出错:graceful-fs

来自分类Dev

由Jetty提供动力

来自分类Dev

SolrCloud-Jetty与Tomcat

来自分类Dev

在Jetty中使用Websockets

来自分类Dev

用Jetty传输文件

来自分类Dev

Ansible 无法重启 jetty

来自分类Dev

Eclipse Jetty 无法启动

来自分类Dev

停止与“ shutdown -H”相同,关机与“ shutdown -P”相同吗?

来自分类Dev

“ shutdown / r”和“ shutdown / g”有什么区别?

来自分类Dev

shutdown选项和cli shutdown有什么区别

来自分类Dev

Socket.Shutdown和线程