我正在使用服务启动包含.jar文件的docker服务。 该服务会自动在领事(v0.7.5)中进行注册,包括运行状况检查。 此检查停留在“紧急”状态,但显示为通过“领事监视器”
我完全删除了服务--health-cmd --health-interval和--health-start-period部分,假设它会在启动时阻止连接,但并没有帮助。
多次重新启动服务后,有时运行状况检查为绿色并返回预期的输出。
有时服务甚至没有注册。
配置为:
在.jar属性中
spring.cloud.consul.host=https://myconsul:8500
spring.cloud.consul.discovery.instanceId = ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
spring.cloud.consul.enabled = true
spring.cloud.consul.discovery.register = true
spring.cloud.consul.discovery.health-check-critical-timeout=5m
spring.cloud.consul.discovery.healthCheckUrl=http://${service.dockerContainerId}/health_check
结果:
在.jar启动时:
...
INFO 1 --- [main] o.s.c.c.s.ConsulServiceRegistry: Registering service with consul:
NewService{
id='myservice-f4f993da9d3abfdba964ca7bf2d26791',
name='myservice',
tags=[secure=false],
address='myservice',
port=80,
enableTagOverride=null,
check=Check{
script='null',
interval='10s',
ttl='null',
http='http://2a90f75d46aa/health_check',
tcp='null',
timeout='null',
deregisterCriticalServiceAfter='5m',
tlsSkipVerify=null,
status='null'
},
checks=null
}
...
https://myconsul:8500/v1/health/service/myservice
...
"Checks": [
{
"Node": "0452c11e1b52",
"CheckID": "serfHealth",
"Name": "Serf Health Status",
"Status": "passing",
"Notes": "",
"Output": "Agent alive and reachable",
"ServiceID": "",
"ServiceName": "",
"CreateIndex": 1267574,
"ModifyIndex": 1267574
},
{
"Node": "0452c11e1b52",
"CheckID": "service:myservice-f4f993da9d3abfdba964ca7bf2d26791",
"Name": "Service 'myservice' check",
"Status": "critical",
"Notes": "",
"Output": "",
"ServiceID": "myservice-f4f993da9d3abfdba964ca7bf2d26791",
"ServiceName": "myservice",
"CreateIndex": 1314956,
"ModifyIndex": 1314956
}
]
但是:
领事监视器-log-level = debug:
[DEBUG] agent: Check 'service:myservice-f4f993da9d3abfdba964ca7bf2d26791' is passing
AND:
从领事容器中致电服务:
curl http://2a90f75d46aa/health_check -v
* Trying 10.0.0.110...
* TCP_NODELAY set
* Connected to 2a90f75d46aa (10.0.0.110) port 80 (#0)
> GET /health_check HTTP/1.1
> Host: 2a90f75d46aa
> User-Agent: curl/7.59.0
> Accept: */*
>
< HTTP/1.1 200
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Vary: Accept-Encoding
< Date: Mon, 14 Oct 2019 13:34:21 GMT
<
* Connection #0 to host 2a90f75d46aa left intact
{"meta":{"name":"myservice","type":"Service","version":"3.9.191014.01","containerid":"2a90f75d46aa","responseCode":"200","responseType":"JSON","responseTime":0,"request":"null"},"payload":{"dependency":[]}}
领事健康检查应为绿色,并返回与手动卷曲请求相同的输出。
任何人都经历过这种行为,知道如何解决吗?