1

我正在使用 Spring Boot / Cloud / Consul(1.0.0.M2 并尝试了截至 2015 年 10 月 6 日的当前代码)。我正在尝试注册/注销使用动态端口和动态 ID 的服务。

我有以下引导程序:

spring:
 cloud:
  consul:
   config:
    enabled: true
    host: localhost
    port: 8500

和 application.yml

spring:
 main: 
  show-banner: false
 application:
  name: helloService
 cloud:
  consul:
   config: 
    prefix: config
    defaultContext: helloService
   discovery: 
    instanceId: ${spring.application.name}:${spring.application.instance.id:${random.value}}
    healthCheckPath: /${spring.application.name}/health
    healthCheckInterval: 15s
endpoints:
 shutdown:
  enabled: true

并且在 config/application/server.port = 0 下的 Key Values 中用于动态端口。

该服务在启动期间已正确注册:

{
"consul": {
    "ID": "consul",
    "Service": "consul",
    "Tags": [],
    "Address": "",
    "Port": 8300
},
"helloService-6596692c4e8af31ddd1589b0d359899f": {
    "ID": "helloService-6596692c4e8af31ddd1589b0d359899f",
    "Service": "helloService",
    "Tags": [],
    "Address": "",
    "Port": 50307
}  }

发出关机后:

curl http://localhost:50307/shutdown -X POST
{"message":"Shutting down, bye..."}

该服务仍处于注册状态,并且运行状况检查开始失败。

{
    "consul": {
        "ID": "consul",
        "Service": "consul",
        "Tags": [],
        "Address": "",
        "Port": 8300
    },
    "helloService-6596692c4e8af31ddd1589b0d359899f": {
        "ID": "helloService-6596692c4e8af31ddd1589b0d359899f",
        "Service": "helloService",
        "Tags": [],
        "Address": "",
        "Port": 50307
} }

什么不见​​了?

4

0 回答 0