spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

SpEL Not Working While Registering Health Check URLs #393

Closed ElderMael closed 5 years ago

ElderMael commented 6 years ago

I have a Spring Boot application deployed as a WAR file in a Tomcat server and I am trying to register a health check with Consul.

I am also using Spring Cloud Consul Config to retrieve the properties needed to register the health check. One of those is:

spring.cloud.consul.discovery.health-check-url=http://#{ T(java.net.InetAddress).getLocalHost().getHostName() }:${server.port}/${server.contextPath}/health

First, because this is a WAR deployment, ${server.port} and ${server.contextPath} do not work so I hardcoded them for now. But I get two services registering with consul: service and service-management. The problem is that the first one provides a health check URL like this:

GET http://#%7B%20T%28java.net.InetAddress%29.getLocalHost%28%29%20%7D:8080/service/health

While the service-management health check URL works fine:

http://server:8080/service/health

Why am I getting only one URL properly interpolated?

spencergibb commented 6 years ago

I don't know what the 'the service-management health check URL' is.

We don't do anything special setting health-check-url. It's just boot's configuration properties.

What version are you using?

ElderMael commented 6 years ago

We are using Spring Boot 1.5.7 with Spring Boot Consul 1.2.1

spencergibb commented 6 years ago

What is 'the service-management health check URL'?

ElderMael commented 6 years ago

It is just a new service that pops up in Consul along with the service, I do not know what it is. It has the same health check URL as the service

spencergibb commented 6 years ago

Right, it doesn't use SpEL

ElderMael commented 6 years ago

Well, the service itself does not properly executes SpEL and just passes the string GET http://#%7B%20T%28java.net.InetAddress%29.getLocalHost%28%29%20%7D:8080/service/health to consul as the healtcheck URL.

spencergibb commented 6 years ago

The service-management service. I don't see how this is a Spring Cloud problem. We have nothing to do with SpEL. All Spring Boot