2021-12-03 11:58:46.767 INFO 673474 --- [ main] io.undertow : starting server: Undertow - 2.2.12.Final 2021-12-03 11:58:46.783 INFO 673474 --- [ main] org.xnio : XNIO version 3.8.4.Final 2021-12-03 11:58:46.795 INFO 673474 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.8.4.Final 2021-12-03 11:58:46.979 INFO 673474 --- [ main] org.jboss.threads : JBoss Threads version 3.1.0.Final 2021-12-03 11:58:47.089 INFO 673474 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 8888 (http) 2021-12-03 11:58:47.108 INFO 673474 --- [ main] c.example.graceful.GracefulApplication : Started GracefulApplication in 3.076 seconds (JVM running for 3.652)
但是在我们测试过程中并没返回503的错误,而是直接拒绝了请求
经过一番测试后,我们发现,如果在接收到kill -2 的信号时,会先打印Commencing graceful shutdown. Waiting for active requests to complete,如果在spring.lifecycle.timeout-per-shutdown-phase设置的时间内处理完所有的请求,那么最后会成功打印Graceful shutdown complete,如果超过spring.lifecycle.timeout-per-shutdown-phase的时间则会作出以下提示
1 2 3 4 5 6
2021-12-03 13:07:15.215 INFO 796937 --- [ionShutdownHook] o.s.b.w.e.undertow.UndertowWebServer : Commencing graceful shutdown. Waiting for active requests to complete 2021-12-03 13:07:20.216 INFO 796937 --- [ionShutdownHook] o.s.c.support.DefaultLifecycleProcessor : Failed to shut down 1 bean with phase value 2147483647 within timeout of 5000ms: [webServerGracefulShutdown] 2021-12-03 13:07:20.217 INFO 796937 --- [ionShutdownHook] o.s.b.w.e.undertow.UndertowWebServer : Graceful shutdown aborted with one or more requests still active 2021-12-03 13:07:20.217 INFO 796937 --- [ionShutdownHook] io.undertow : stopping server: Undertow - 2.2.12.Final