Spring Coudマイクロサービスが優雅に停止します.
3867 ワード
優雅停止サービス
Spring Bootは、Springフレームワークとして、「コンベンションOver Configration」の理念を優先する最適な実践の産物として、独立運行、製品レベルのSpringフレームベースの応用を迅速に作成してくれます.Spring Bootのほとんどは、非常に少ない配置だけで、急速に実行できます.マイクロサービス(MicroServices)とのことです.かなり合うマイクロフレームです.
Spring Bootは、Springフレームワークとして、「コンベンションOver Configration」の理念を優先する最適な実践の産物として、独立運行、製品レベルのSpringフレームベースの応用を迅速に作成してくれます.Spring Bootのほとんどは、非常に少ない配置だけで、急速に実行できます.マイクロサービス(MicroServices)とのことです.かなり合うマイクロフレームです.
spring-boot-starter-actuator
には、優雅な停止サービスが提供されている./shutdown
構成:<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>1.4.3.RELEASEversion>
<relativePath/>
parent>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-actuatorartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
dependencies>
pom.xml
構成:# shutdown
endpoints.shutdown.enabled=true
#
endpoints.shutdown.sensitive=false
サービスが開始されると、POST要求をlinuxのcurlコマンドで送ることができます.優雅にサービスを停止します.curl -X POST host:port/shutdown
{"message":"Shutting down, bye..."}
サービス停止フラグc.n.e.EurekaDiscoveryClientConfiguration : Unregistering application eureka-server with eureka with status DOWN
com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
c.n.eureka.DefaultEurekaServerContext : Shutting down ...
c.n.eureka.DefaultEurekaServerContext : Shut down
o.apache.catalina.core.StandardService : Stopping service Tomcat
o.a.c.c.C.[Tomcat].[localhost].[/] : Destroying Spring FrameworkServlet 'dispatcherServlet'