当Tomcat停止运行时,请求会发生什么?

16

当您以“正常”的方式停止或重新启动Tomcat时,正在处理的HTTP请求会发生什么情况?它们会一直处理直到响应完成,还是HTTP线程会被中断?是否有一种配置优雅停止的方法?

2个回答

16

2
好的,出于好奇,这会导致Tomcat拒绝新请求,同时仍允许Servlet完成处理现有请求吗? - ametren
有没有关于它如何拒绝请求的文档?例如,它是简单地不允许TCP套接字连接还是向客户端发送RST? - suh
在Linux下,<Context path="/myapp" unloadDelay="10000"/>对我有效,但只有大写字母_C_ontext。 - user2081279
@user2081279,你把上述更改粘贴到哪里了?在哪个文件中?我有点困惑。谢谢。 - mungaih pk
@mungaih pk,有几种可能的解决方案。一种方法是在 server.xml 中进行设置,如下所示:<Context path="/mycontextroot" unloadDelay="10000"/>,或者您可以在 context.xml 中进行设置,如下所示:<Context unloadDelay="10000"><Resource name="jdbc/imageserver" ... 如果您对 Docker/Kubernetes 的上下文感兴趣,请参阅 https://dev59.com/GK3la4cB1Zd3GeqPL2N-。 - user2081279

1

IT只是终止请求并断开请求-响应链接。然后你会得到...

无法连接

  Browser can't establish a connection to the server at Host:port.

  The site could be temporarily unavailable or too busy. Try again in a few moments.
  If you are unable to load any pages, check your computer's network connection.
  If your computer or network is protected by a firewall or proxy, make sure that Browser is permitted to access the Web.

无法处理。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接