【问题标题】:Spring Cloud Consul health check configurationSpring Cloud Consul 健康检查配置
【发布时间】:2017-05-27 06:34:05
【问题描述】:

我正在将 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

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

【问题讨论】:

    标签: spring-boot spring-cloud consul


    【解决方案1】:

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

    healthCheckPath 只改变路径,不改变主机和端口。

    【讨论】:

      猜你喜欢
      • 2019-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 2018-01-16
      • 2016-05-06
      • 2018-12-10
      • 1970-01-01
      相关资源
      最近更新 更多