Skip to content

Commit

Permalink
feat(openchallenges): update the Eureka config bean to set port for t…
Browse files Browse the repository at this point in the history
…he org service (#2763)
  • Loading branch information
tschaffter authored Aug 20, 2024
1 parent ac5afbe commit 7643b94
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.UnknownHostException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
Expand All @@ -15,6 +16,9 @@ public class EurekaInstanceConfiguration {

private static final Logger LOGGER = LoggerFactory.getLogger(EurekaInstanceConfiguration.class);

@Value("${server.port}")
private String port;

/**
* If the application is planned to be deployed to an AWS cloud, the Eureka instance must be
* configured to be AWS-aware. This can be done by customizing the EurekaInstanceConfigBean.
Expand All @@ -38,9 +42,9 @@ public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
LOGGER.error("Unable to get the host address.", e);
}
bean.setIpAddress(ip);
// bean.setPreferIpAddress(true);
// bean.setNonSecurePortEnabled(true);
// bean.setNonSecurePort(Integer.parseInt(port));
bean.setPreferIpAddress(true);
bean.setNonSecurePortEnabled(true);
bean.setNonSecurePort(Integer.parseInt(port));
return bean;
}
}

0 comments on commit 7643b94

Please sign in to comment.