{"id":14485,"date":"2024-04-24T14:43:54","date_gmt":"2024-04-24T06:43:54","guid":{"rendered":"https:\/\/92it.top\/?p=14485"},"modified":"2024-04-24T14:43:55","modified_gmt":"2024-04-24T06:43:55","slug":"spring-boot-%e4%bc%98%e9%9b%85%e5%81%9c%e6%9c%ba-graceful-shutdown","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=14485","title":{"rendered":"Spring Boot \u4f18\u96c5\u505c\u673a\u2014\u2014Graceful Shutdown"},"content":{"rendered":"\n<p>\u5728\u7cfb\u7edf\u751f\u547d\u5468\u671f\u4e2d, \u514d\u4e0d\u4e86\u8981\u505a\u5347\u7ea7\u90e8\u7f72, \u5bf9\u4e8e\u5173\u952e\u670d\u52a1, \u6211\u4eec\u5e94\u8be5\u80fd\u505a\u5230\u4e0d\u505c\u670d\u52a1\u5b8c\u6210\u5347\u7ea7 (perform a zero downtime upgrade), \u5bf9\u4e8e\u4e00\u822c\u7cfb\u7edf, \u5e94\u8be5\u505a\u5230\u4f18\u96c5\u5730\u505c\u670d\u52a1\u3002<br>\u4ee5\u524d\u7ecf\u5e38\u4f7f\u7528<code>kill -9 &lt;pid><\/code>\u91ce\u86ee\u7c97\u66b4\u8fdb\u884c\u505c\u6b62\uff0c\u53ef\u80fd\u5bfc\u81f4\u6b64\u4e1a\u52a1\u903b\u8f91\u6267\u884c\u5931\u8d25\uff0c\u5728\u4e00\u4e9b\u4e1a\u52a1\u573a\u666f\u4e0b\u4f1a\u51fa\u73b0\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0c\u4e8b\u52a1\u903b\u8f91\u4e0d\u4f1a\u56de\u6eda\u3002\u6211\u4eec\u9700\u8981\u5728 web \u5bb9\u5668\u5173\u95ed\u65f6\uff0cweb \u670d\u52a1\u5668\u5c06\u4e0d\u518d\u63a5\u6536\u65b0\u8bf7\u6c42\uff0c\u5e76\u5c06\u6709\u4e2a\u7f13\u51b2\u671f\u7b49\u5f85\u6d3b\u52a8\u8bf7\u6c42\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u5982\u4f55\u505a\u5230\u4e0d\u505c\u670d\u52a1\u7684\u5347\u7ea7? \u9700\u8981\u505a\u5230\u4e0b\u9762\u4e24\u70b9:<\/p>\n\n\n\n<ul>\n<li>\u670d\u52a1\u672c\u8eab\u5e94\u8be5\u90e8\u7f72\u591a\u4efd, \u524d\u9762\u5e94\u8be5\u6709 LVS\/Haproxy \u5c42\u6216\u8005\u670d\u52a1\u6ce8\u518c\u7ec4\u4ef6.<\/li>\n\n\n\n<li>\u6bcf\u4e00\u4efd\u670d\u52a1\u80fd\u88ab\u4f18\u96c5\u505c\u673a, \u5373: \u5728 kill pid \u547d\u4ee4\u53d1\u51fa\u540e, \u7a0b\u5e8f\u5e94\u8be5\u80fd\u62d2\u7edd\u65b0\u7684\u8bf7\u6c42, \u4f46\u5e94\u8be5\u7ee7\u7eed\u5b8c\u6210\u5df2\u6709\u8bf7\u6c42\u7684\u5904\u7406\u3002<\/li>\n<\/ul>\n\n\n\n<p>Spring Boot 2.3 \u65b0\u7279\u6027\u4f18\u96c5\u505c\u673a\uff0c\u5176\u4ed6\u7248\u672c\u9700\u8981\u7f16\u5199\u76f8\u5173\u4ee3\u7801\u6765<code>hook<\/code> \u5173\u673a\u4e8b\u4ef6\uff0c\u53ef\u4ee5\u7f51\u4e0a\u641c\u7d22\u5176\u4ed6\u6587\u7ae0\u3002<\/p>\n\n\n\n<p><strong>\u9884\u5907\u77e5\u8bc6<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>============================<br>Linux kill \u547d\u4ee4<br>============================<\/p>\n\n\n\n<p>kill \u547d\u4ee4\u5e38\u7528\u7684\u4fe1\u53f7\u9009\u9879:<\/p>\n\n\n\n<ul>\n<li>(1) kill -2 pid \u5411\u6307\u5b9a pid \u53d1\u9001 SIGINT \u4e2d\u65ad\u4fe1\u53f7, \u7b49\u540c\u4e8e ctrl+c.<\/li>\n\n\n\n<li>(2) kill -9 pid, \u5411\u6307\u5b9a pid \u53d1\u9001 SIGKILL \u7acb\u5373\u7ec8\u6b62\u4fe1\u53f7.<\/li>\n\n\n\n<li>(3) kill -15 pid, \u5411\u6307\u5b9a pid \u53d1\u9001 SIGTERM \u7ec8\u6b62\u4fe1\u53f7.<\/li>\n\n\n\n<li>(4) kill pid \u7b49\u540c\u4e8e kill 15 pid<\/li>\n<\/ul>\n\n\n\n<p>SIGINT\/SIGKILL\/SIGTERM \u4fe1\u53f7\u7684\u533a\u522b:<\/p>\n\n\n\n<ul>\n<li>(1) SIGINT (ctrl+c) \u4fe1\u53f7 (\u4fe1\u53f7\u7f16\u53f7\u4e3a 2), \u4fe1\u53f7\u4f1a\u88ab\u5f53\u524d\u8fdb\u7a0b\u6811\u63a5\u6536\u5230, \u4e5f\u5c31\u8bf4, \u4e0d\u4ec5\u5f53\u524d\u8fdb\u7a0b\u4f1a\u6536\u5230\u8be5\u4fe1\u53f7, \u800c\u4e14\u5b83\u7684\u5b50\u8fdb\u7a0b\u4e5f\u4f1a\u6536\u5230.<\/li>\n\n\n\n<li>(2) SIGKILL \u4fe1\u53f7 (\u4fe1\u53f7\u7f16\u53f7\u4e3a 9), \u7a0b\u5e8f\u4e0d\u80fd\u6355\u83b7\u8be5\u4fe1\u53f7, \u6700\u7c97\u66b4\u6700\u5feb\u901f\u7ed3\u675f\u7a0b\u5e8f\u7684\u65b9\u6cd5.<\/li>\n\n\n\n<li>(3) SIGTERM \u4fe1\u53f7 (\u4fe1\u53f7\u7f16\u53f7\u4e3a 15), \u4fe1\u53f7\u4f1a\u88ab\u5f53\u524d\u8fdb\u7a0b\u63a5\u6536\u5230, \u4f46\u5b83\u7684\u5b50\u8fdb\u7a0b\u4e0d\u4f1a\u6536\u5230, \u5982\u679c\u5f53\u524d\u8fdb\u7a0b\u88ab kill \u6389, \u5b83\u7684\u7684\u5b50\u8fdb\u7a0b\u7684\u7236\u8fdb\u7a0b\u5c06\u53d8\u6210 init \u8fdb\u7a0b (init \u8fdb\u7a0b\u662f\u90a3\u4e2a pid \u4e3a 1 \u7684\u8fdb\u7a0b)<\/li>\n<\/ul>\n\n\n\n<p>\u4e00\u822c\u8981\u7ed3\u675f\u67d0\u4e2a\u8fdb\u7a0b, \u6211\u4eec\u5e94\u8be5\u4f18\u5148\u4f7f\u7528 <strong>kill pid<\/strong> , \u800c\u4e0d\u662f kill -9 pid. \u5982\u679c\u5bf9\u5e94\u7a0b\u5e8f\u63d0\u4f9b\u4f18\u96c5\u5173\u95ed\u673a\u5236\u7684\u8bdd, \u5728\u5b8c\u5168\u9000\u51fa\u4e4b\u524d, \u5148\u53ef\u4ee5\u505a\u4e00\u4e9b\u5584\u540e\u5904\u7406\u3002<\/p>\n\n\n\n<p><strong>\u5b98\u65b9\u8bf4\u660e<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"697\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-1024x697.png\" alt=\"\" class=\"wp-image-14487\" style=\"width:508px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-1024x697.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-300x204.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-768x522.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-1536x1045.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-2048x1393.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-830x565.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-230x156.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-350x238.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-64-480x327.png 480w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<pre class=\"wp-block-preformatted\">Graceful shutdown<br>Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. When enabled using server.shutdown=graceful, upon shutdown, the web server will no longer permit new requests and will wait for a grace period for active requests to complete. The grace period can be configured using spring.lifecycle.timeout-per-shutdown-phase.<br><\/pre>\n\n\n\n<p><strong>\u672c\u5730\u73af\u5883\u5347\u7ea7<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e0a\u56fe\u53ef\u77e5<code>Spring boot<\/code>\u7684\u7248\u672c\u8981\u6c422.3\u53ca\u4ee5\u4e0a\uff0c<code>Tomcat<\/code>\u7248\u672c9.0.33\u6216\u66f4\u65b0\u3002<br>\u6211\u7684\u7248\u672c\u5206\u522b\u4e3a2.2.2\u548c9.0.29\u4e0d\u7b26\u5408\u8981\u6c42\uff0c\u7248\u672c\u67e5\u770b\u65b9\u6cd5\u89c1\u4e0b\u56fe\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"542\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-1024x542.png\" alt=\"\" class=\"wp-image-14488\" style=\"width:482px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-1024x542.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-300x159.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-768x407.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-830x439.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-230x122.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-350x185.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65-480x254.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-65.png 1360w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><code>pom.xml<\/code>\u5347\u7ea7<code>&lt;artifactId>spring-boot-starter-parent&lt;\/artifactId><\/code>\u7248\u672c\u53f7\u4e3a\uff1a<code>&lt;version>2.3.0.RELEASE&lt;\/version><\/code><br>\u63d0\u793a\u9519\u8bef\uff1a<code>Could not find artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.0.RELEASE in nexus-aliyun(http:\/\/maven.aliyun.com\/nexus\/content\/groups\/public)<\/code><br>\u5e94\u8be5\u662f\u8fd9\u4e2a\u963f\u91cc\u4e91\u4ed3\u5e93\u5730\u5740\u627e\u4e0d\u5230\u6700\u65b0\u7248\u672c<code>2.3.0.RELEASE<\/code>\u7684<code>Spring boot<\/code>\u4f9d\u8d56\uff0c\u540e\u5728\u4ed3\u5e93<code>grails-core<\/code>\u627e\u5230\uff0c\u4fee\u6539\u963f\u91cc\u4e91\u7684maven\u4ed3\u5e93\u5730\u5740\u4e3a\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  &lt;mirrors>\n        &lt;mirror>\n            &lt;id>aliyunmaven-public&lt;\/id>\n            &lt;mirrorOf>*&lt;\/mirrorOf>\n            &lt;name>\u963f\u91cc\u4e91\u516c\u5171\u4ed3\u5e93&lt;\/name>\n            &lt;url>https:\/\/maven.aliyun.com\/repository\/public&lt;\/url>\n        &lt;\/mirror>\n         &lt;mirror>\n            &lt;id>aliyunmaven-grails&lt;\/id>\n            &lt;mirrorOf>*&lt;\/mirrorOf>\n            &lt;name>\u963f\u91cc\u4e91grails\u4ed3\u5e93&lt;\/name>\n            &lt;url>https:\/\/maven.aliyun.com\/repository\/grails-core&lt;\/url>\n        &lt;\/mirror>\n    &lt;\/mirrors>\n<\/pre>\n\n\n\n<p>\u70b9\u51fb<code>Maven<\/code>\u7a97\u53e3\u7684\u91cd\u65b0\u5bfc\u5165\u4f9d\u8d56\u6309\u94ae\uff0c\u91cd\u65b0\u62c9\u53d6\u4f9d\u8d56\u5305\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"586\" height=\"436\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66.png\" alt=\"\" class=\"wp-image-14489\" style=\"width:270px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66.png 586w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66-300x223.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66-230x171.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66-350x260.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-66-480x357.png 480w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/figure><\/div>\n\n\n<p>\u6ca1\u6709\u62a5\u9519\uff0c\u5f00\u59cb\u540c\u6b65\u6700\u65b0\u7248\u7684\u4f9d\u8d56\u9879\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"380\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-1024x380.png\" alt=\"\" class=\"wp-image-14490\" style=\"width:522px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-1024x380.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-300x111.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-768x285.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-830x308.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-230x85.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-350x130.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67-480x178.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-67.png 1342w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>\u518d\u6b21\u67e5\u770b\u7248\u672c\uff0c\u5df2\u7ecf\u7b26\u5408\u8981\u6c42<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"503\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-1024x503.png\" alt=\"\" class=\"wp-image-14491\" style=\"width:530px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-1024x503.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-300x147.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-768x378.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-830x408.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-230x113.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-350x172.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68-480x236.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/04\/image-68.png 1184w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u5f00\u542fGraceful Shutdown\u914d\u7f6e<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728\u6700\u65b0\u7248\u7684<code>Spring Boot 2.3<\/code>\u4e2d\u7ec8\u4e8e\u96c6\u6210\u4e86\u4f18\u96c5\u9000\u51fa\uff08Graceful shutdown\uff09\uff0c\u5728\u5b98\u65b9\u6587\u6863\u4e2d\u53ef\u4ee5\u770b\u5230\u5185\u7f6e\u7684 web \u670d\u52a1\u5668\uff08<code>Jetty\u3001Reactor Netty\u3001Tomcat \u548c Undertow<\/code>\uff09\u4ee5\u53ca\u53cd\u5e94\u5f0f\u548c\u57fa\u4e8e Servlet \u7684 web \u5e94\u7528\u7a0b\u5e8f\u90fd\u652f\u6301\u4f18\u96c5\u9000\u51fa\u529f\u80fd\u3002\u5f53<code>server.shutdown=graceful<\/code>\u542f\u7528\u65f6\uff0c\u5728 web \u5bb9\u5668\u5173\u95ed\u65f6\uff0cweb \u670d\u52a1\u5668\u5c06\u4e0d\u518d\u63a5\u6536\u65b0\u8bf7\u6c42\uff0c\u5e76\u5c06\u7b49\u5f85\u6d3b\u52a8\u8bf7\u6c42\u5b8c\u6210\u7684\u7f13\u51b2\u671f\u3002\u7f13\u51b2\u671f <code>timeout-per-shutdown-phase<\/code> \u914d\u7f6e<br>\u9ed8\u8ba4\u65f6\u95f4\u4e3a 20s, \u610f\u5473\u7740\u6700\u5927\u7b49\u5f85 20s\uff0c\u8d85\u65f6\u65e0\u8bba\u7ebf\u7a0b\u4efb\u52a1\u662f\u5426\u6267\u884c\u5b8c\u6bd5\u90fd\u4f1a\u505c\u673a\u5904\u7406\uff0c\u4e00\u5b9a\u8981\u5408\u7406\u8bbe\u7f6e\u7f13\u51b2\u671f\u5927\u5c0f\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u65b9\u5f0f\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u914d\u7f6e\u4e00\u4e0b<code>yml<\/code>\u6587\u4ef6\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server:\n  shutdown: graceful #\u5f00\u542f\u4f18\u96c5\u505c\u673a\uff0c\u9ed8\u8ba4\u662f\u7acb\u5373\u505c\u673aIMMEDIATE\nspring:\n  lifecycle:\n    timeout-per-shutdown-phase: 20s #\u7f13\u51b2\u5668\u5373\u6700\u5927\u7b49\u5f85\u65f6\u95f4\n<\/pre>\n\n\n\n<p><code>properties<\/code>\u6587\u4ef6\u65b9\u5f0f:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">server.shutdown=graceful\nspring.lifecycle.timeout-per-shutdown-phase=20s\n<\/pre>\n\n\n\n<p><strong>\u4f53\u9a8c<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>1. \u4ee3\u7801\uff0c\u6a21\u62df\u9700\u898115s\u957f\u65f6\u95f4\u624d\u80fd\u5904\u7406\u5b8c\u6210\u7684\u4e1a\u52a1\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    @ApiVersion(5)\n    @RequestMapping(value = \"\/gracefulshutdown\")\n    \/\/ http:\/\/localhost:8555\/v5\/packageIndex\/gracefulshutdown\n    public String gracefulShutdown() throws InterruptedException {\n        \/\/ \u6a21\u62df\u4e1a\u52a1\u8017\u65f6\u5904\u7406\u6d41\u7a0b\n        Thread.sleep(15 * 1000L);\n        return \"\u4e1a\u52a1\u5904\u7406\u5b8c\u6bd5\";\n    }\n<\/pre>\n\n\n\n<p>2.\u6253\u5305\u540e\u4e0a\u4f20<code>Linux<\/code>\u670d\u52a1\u5668\uff0c\u542f\u52a8\u9879\u76ee<code># java -jar bank_router-1.0.0-SNAPSHOT-exec.jar<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@izuf672oio5mc4fbyj0s0jz mp-springboot]# java -jar bank_router-1.0.0-SNAPSHOT-exec.jar \n2020-05-24 21:17:50.538  INFO 1397 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8296e9c7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)\n\n  .   ____          _            __ _ _\n \/\\\\ \/ ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\\/ _` | \\ \\ \\ \\\n \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\n  '  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/\n =========|_|==============|___\/=\/_\/_\/_\/\n :: Spring Boot ::        (v2.3.0.RELEASE)\n\n<\/pre>\n\n\n\n<p>3.\u8c03\u7528\u670d\u52a1\u5730\u5740:<code>curl localhost:8080\/v5\/packageIndex\/gracefulshutdown<\/code>\uff0c15\u79d2\u540e\u624d\u6709\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>4.\u5173\u95ed\u670d\u52a1\uff0c\u6267\u884c<code>kill -2<\/code>\u6216\u8005<code>Ctrl + C<\/code>\u3002<\/p>\n\n\n\n<p>\u6b64\u5904\u6267\u884c<code>kill -2<\/code> \u800c\u4e0d\u662f<code>kill -9<\/code>\u3002<code>kill -2<\/code> \u76f8\u5f53\u4e8e\u5feb\u6377\u952e<code>Ctrl + C<\/code>\u4f1a\u89e6\u53d1 Java \u7684 <code>ShutdownHook<\/code> \u4e8b\u4ef6\u5904\u7406\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@izuf672oio5mc4fbyj0s0jz ~]# ps aux |grep java\nroot      1397 40.3 12.0 4651892 948500 pts\/0  Sl+  21:17   0:37 java -jar bank_router-1.0.0-SNAPSHOT-exec.jar\n<\/pre>\n\n\n\n<p>5.\u670d\u52a1\u7aef\u63a5\u6536\u5230\u4e86\u6307\u4ee4\uff0c\u8fdb\u884c\u5173\u95ed\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\u4e2d\u95f4\u670913\u79d2\u7b49\u5f85\u7ed3\u675f\u6240\u6709\u7684\u8bf7\u6c42\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">2020-05-24 21:22:07 [SpringContextShutdownHook] INFO  o.s.boot.web.embedded.tomcat.GracefulShutdown:53 -Commencing graceful shutdown. Waiting for active requests to complete\n2020-05-24 21:22:07 [tomcat-shutdown] INFO  o.s.boot.web.embedded.tomcat.GracefulShutdown:78 -Graceful shutdown complete\n2020-05-24 21:22:07 [SpringContextShutdownHook] INFO  o.s.boot.web.embedded.tomcat.GracefulShutdown:53 -Commencing graceful shutdown. Waiting for active requests to complete\n###############\n\u8fd9\u4e00\u6bb5\u65f6\u95f4\u95f4\u9694\u662f\u6211\u8bbf\u95ee\u7684url\u8fd8\u6ca1\u6709\u8fd4\u56de\u7ed3\u679c\uff0c\u7b49\u5904\u7406\u5b8c\u6211\u7684\u8bbf\u95ee\u540e\u7ee7\u7eed\u4e0b\u9762\u7684\u5173\u95ed\u64cd\u4f5c\u3002\n###############\n2020-05-24 21:22:20 [tomcat-shutdown] INFO  o.s.boot.web.embedded.tomcat.GracefulShutdown:78 -Graceful shutdown complete\n2020-05-24 21:22:20 [SpringContextShutdownHook] INFO  o.s.scheduling.concurrent.ThreadPoolTaskScheduler:218 -Shutting down ExecutorService\n2020-05-24 21:22:20 [SpringContextShutdownHook] INFO  o.s.orm.jpa.LocalContainerEntityManagerFactoryBean:598 -Closing JPA EntityManagerFactory for persistence unit 'default'\n2020-05-24 21:22:20 [SpringContextShutdownHook] INFO  com.alibaba.druid.pool.DruidDataSource:1948 -{dataSource-1} closing ...\n2020-05-24 21:22:20 [SpringContextShutdownHook] INFO  com.alibaba.druid.pool.DruidDataSource:2020 -{dataSource-1} closed\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7cfb\u7edf\u751f\u547d\u5468\u671f\u4e2d, \u514d\u4e0d\u4e86\u8981\u505a\u5347\u7ea7\u90e8\u7f72, \u5bf9\u4e8e\u5173\u952e\u670d\u52a1, \u6211\u4eec\u5e94\u8be5\u80fd\u505a\u5230\u4e0d\u505c\u670d\u52a1\u5b8c\u6210\u5347\u7ea7 (perform a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14485"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14485"}],"version-history":[{"count":4,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14485\/revisions"}],"predecessor-version":[{"id":14494,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14485\/revisions\/14494"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}