简体   繁体   English

无法从领事注销服务(Spring 启动应用程序)

[英]Unable to deregister service(Spring boot app) from consul

Unable to deregister the service from Consul.无法从 Consul 注销服务。 Basically Consul official page said that it will deregister service automatically but in my case it won't work like said.基本上 Consul 官方页面说它会自动取消注册服务,但在我的情况下它不会像所说的那样工作。

https://www.consul.io/docs/agent/basics.html https://www.consul.io/docs/agent/basics.html

Hi Referring to the consul Life-cycle its says that嗨,提到领事生命周期,它说

To prevent an accumulation of dead nodes (nodes in either failed or left states), Consul will automatically remove dead nodes out of the catalog.为了防止死节点(处于失败或离开状态的节点)的积累,Consul 会自动将死节点从目录中删除。 This process is called reaping.这个过程称为收割。 This is currently done on a configurable interval of 72 hours (changing the reap interval is not recommended due to its consequences during outage situations).目前这是在 72 小时的可配置间隔内完成的(不建议更改收获间隔,因为它会在中断情况下产生后果)。 Reaping is similar to leaving, causing all associated services to be deregistered. Reaping 类似于离开,导致所有相关服务被注销。

This is my bootstrap.yml file这是我的 bootstrap.yml 文件

server:
 port: 8089
spring:
 application:
   name: ***-service
 cloud:
   consul:
     host: consul-ui
     port: 8500
     discovery:
       deregister: true
       instance-id: ${spring.application.name}:${random.value}
       enabled: true
       register: true
       health-check-interval: 20s
       prefer-ip-address: true
     config:
       enabled: true
       prefix: configuration
       defaultContext: shared
       format: YAML
       data-key: data
       watch:
         enabled: true
 endpoints:
   shutdown:
     enabled: true

In Consul UI after deleting service using purge command, still shows on Consul UI.使用清除命令删除服务后,在 Consul UI 中,仍然显示在 Consul UI 上。 So meant that it is not been deregister from Consul所以意味着它没有被领事注销

You need to configure this on Consul, as your apps seems to not exit gracefully.您需要在 Consul 上进行配置,因为您的应用程序似乎无法正常退出。 Checkout the consul config property deregister_critical_service_after :检查领事配置属性deregister_critical_service_after

In Consul 0.7 and later, checks that are associated with a service may also contain an optional deregister_critical_service_after field, which is a timeout in the same Go time format as interval and ttl .在 Consul 0.7 及更高版本中,与服务相关联的检查还可能包含可选的deregister_critical_service_after字段,它是与intervalttl具有相同 Go 时间格式的超时。 If a check is in the critical state for more than this configured value, then its associated service (and all of its associated checks) will automatically be deregistered.如果检查处于临界状态的时间超过此配置值,则其关联的服务(及其所有关联的检查)将自动取消注册。 The minimum timeout is 1 minute, and the process that reaps critical services runs every 30 seconds, so it may take slightly longer than the configured timeout to trigger the deregistration.最小超时时间为1分钟,收割关键服务的进程每30秒运行一次,因此触发注销的时间可能比配置的超时时间稍长。 This should generally be configured with a timeout that's much, much longer than any expected recoverable outage for the given service.这通常应该配置一个超时,该超时比给定服务的任何预期可恢复中断要长得多。

That documentation is about consul nodes, not service nodes.该文档是关于领事节点,而不是服务节点。

How exactly are you terminating the application?您究竟是如何终止应用程序的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM