From 7643b94378c9cfc62241c35c0b95367f4152d342 Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Mon, 19 Aug 2024 17:24:39 -0700 Subject: [PATCH] feat(openchallenges): update the Eureka config bean to set port for the org service (#2763) --- .../configuration/EurekaInstanceConfiguration.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openchallenges/organization-service/src/main/java/org/sagebionetworks/openchallenges/organization/service/configuration/EurekaInstanceConfiguration.java b/apps/openchallenges/organization-service/src/main/java/org/sagebionetworks/openchallenges/organization/service/configuration/EurekaInstanceConfiguration.java index fbd6ad7519..934a252a0a 100644 --- a/apps/openchallenges/organization-service/src/main/java/org/sagebionetworks/openchallenges/organization/service/configuration/EurekaInstanceConfiguration.java +++ b/apps/openchallenges/organization-service/src/main/java/org/sagebionetworks/openchallenges/organization/service/configuration/EurekaInstanceConfiguration.java @@ -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; @@ -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. @@ -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; } }