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

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

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

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

Loading…
Cancel
Save