Spring Cloud Consul运行状况检查配置

时间:2017-01-12 08:30:10

标签: spring-boot spring-cloud consul

我正在运行Spring Boot应用程序作为Docker容器。到目前为止这个工作正常,但在尝试使用Spring Cloud Consul时,它给了我一些头痛。它从Consul KVS中读取配置就好了,但健康检查似乎正在起作用。

默认运行状况检查使用docker容器的主机名,例如http://users-microservice/health。显然,从Consul访问时无法解决这个问题。

没问题,documentation提到您可以在bootstrap.yml文件中使用 healthCheckPath 进行配置。这就是我现在所拥有的:

spring:
    application:
        name: users-microservice
    cloud:
        consul:
        host: myserver.com
        port: 8500
        config:
            prefix: API-CONFIG
            profileSeparator: '__'
        discovery:
            tags: users-microservice
            healthCheckPath: http://myserver.com:${server.port}/status
            healthCheckInterval: 30s

不幸的是,这个变量似乎以与我的预期不同的方式使用。这是Consul试图达到的目标:

Get http://users:18090http//myserver.com:18090/status: dial tcp: unknown port tcp/18090http

我该如何解决这个问题?我应该设置一些未记录的配置参数吗?

1 个答案:

答案 0 :(得分:1)

使用spring.cloud.consul.discovery.healthCheckUrl=http://myserver.com:${server.port}/status

healthCheckPath仅更改路径,而不是主机和端口。

相关问题