增加服务实例自身健康检查

pull/34/head
bruceppeng 3 years ago
parent 882b23ef29
commit f43d557155

@ -10,7 +10,7 @@ spring:
discovery:
heartbeat:
enabled: true
health-check-url: http://localhost:48080/discovery/service/caller/healthCheck
health-check-url: /discovery/service/caller/healthCheck
consul:
port: 8500
host: 127.0.0.1

@ -181,7 +181,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
@Override
public void run() {
try {
String healthCheckUrl = polarisProperties.getHealthCheckUrl();
String healthCheckUrl = String.format("http://%s:%s%s", heartbeatRequest.getHost(), heartbeatRequest.getPort(), polarisProperties.getHealthCheckUrl());
//先判断是否配置了health-check-url如果配置了需要先进行服务实例健康检查如果健康检查通过则进行心跳上报如果不通过则不上报心跳
if (Strings.isNotEmpty(healthCheckUrl) && !OkHttpUtil.get(healthCheckUrl, null)){
log.error("polaris health check failed");

Loading…
Cancel
Save