Commit 198cb599 by Spencer Gibb

updated sidecar so the health and info urls go to sidecar, but homepage and…

updated sidecar so the health and info urls go to sidecar, but homepage and non-secure-port go to local app
parent dc12c235
......@@ -73,5 +73,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -19,7 +19,7 @@ public class LocalApplicationHealthIndicator extends AbstractHealthIndicator {
@SuppressWarnings("unchecked")
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
URI uri = properties.getLocalHealthUri();
URI uri = properties.getHealthUri();
if (uri == null) {
builder.up();
return;
......
package org.springframework.cloud.netflix.sidecar;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -12,6 +14,8 @@ import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties
@ConditionalOnExpression("${sidecar.enabled:true}")
public class SidecarConfiguration {
@Value("${server.port:${SERVER_PORT:${PORT:8080}}}")
private int serverPort = 8080;
@Bean
public SidecarProperties sidecarProperties() {
......@@ -19,6 +23,22 @@ public class SidecarConfiguration {
}
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfigBean() {
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean();
int port = sidecarProperties().getPort();
config.setNonSecurePort(port);
String scheme = config.getSecurePortEnabled()? "https" : "http";
config.setStatusPageUrl(scheme + "://" + config.getHostname() + ":" + serverPort + config.getStatusPageUrlPath());
config.setHealthCheckUrl(scheme + "://" + config.getHostname() + ":" + serverPort + config.getHealthCheckUrlPath());
config.setHomePageUrl(scheme + "://" + config.getHostname() + ":" + port + config.getHomePageUrlPath());
return config;
}
@Bean
public LocalApplicationHealthIndicator localApplicationHealthIndicator() {
return new LocalApplicationHealthIndicator();
}
......
......@@ -11,5 +11,7 @@ import java.net.URI;
@Data
@ConfigurationProperties("sidecar")
public class SidecarProperties {
private URI localHealthUri;
private URI healthUri;
private URI homePageUri;
private int port;
}
......@@ -5,7 +5,20 @@ spring:
name: sidecarTest
sidecar:
local-health-uri: http://localhost:8081/health
port: 8000
health-uri: http://localhost:8000/src/test/resources/health.json
eureka:
instance:
app-group-name: mysidecargroup
endpoints:
refresh:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
zuul:
proxy:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment