I am using following pom.xml for my eureka server. I have couple of micro services which are registered with eureka server.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.etp</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka-server</name>
<description>Spring Boot eureka-server</description>
<properties>
<!-- <java.version>1.8</java.version> -->
<!--Build-Date -->
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>dd-MMM-yyyy</maven.build.timestamp.format>
<!--Build-Date -->
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
All services gets registered approximately and then they automatically shuts down themselves either with docker status code 0 or 137. I tried to check logs for both and found following stack for both status code services
log="24-09-2021 09:45:33.965 [DiscoveryClient-InstanceInfoReplicator-0] INFO com.netflix.discovery.DiscoveryClient.register - DiscoveryClient_MYMICROSERVICE/mymicroservice:56e852b73630a712fbdf9defedaa6cef: registering service..."
log="24-09-2021 09:45:33.910 [SpringContextShutdownHook] ERROR com.netflix.discovery.DiscoveryClient.notify - Saw local status change event StatusChangeEvent [timestamp=1632476733910, current=DOWN, previous=UP]"
log="24-09-2021 09:45:33.889 [SpringContextShutdownHook] INFO org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry.deregister - Unregistering application MYMICROSERVICE with eureka with status DOWN"
log="24-09-2021 09:45:34.598 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.shutdown - Shutting down DiscoveryClient ..."
container_name=/mymicroservice source=stdout log="24-09-2021 09:45:34.524 [SpringContextShutdownHook] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.shutdown - Shutting down ExecutorService 'applicationTaskExecutor'" container_id=5b50472ae3437072dfe79c664a71dc305513d928b7173839c904dfe1abd7081e
container_name=/mymicroservice source=stdout log="24-09-2021 09:45:34.034 [DiscoveryClient-InstanceInfoReplicator-0] INFO com.netflix.discovery.DiscoveryClient.register - DiscoveryClient_MYMICROSERVICE/mymicroservice:56e852b73630a712fbdf9defedaa6cef - registration status: 204" container_id=5b50472ae3437072dfe79c664a71dc305513d928b7173839c904dfe1abd7081e
log="24-09-2021 09:45:37.629 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.unregister - Unregistering ..."
log="24-09-2021 09:45:42.755 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.unregister -DiscoveryClient_MYMICROSERVICE/mymicroservice:56e852b73630a712fbdf9defedaa6cef - deregister status: 200"
log="24-09-2021 09:45:43.030 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.shutdown - Completed shut down of DiscoveryClient"
With log level TRACE I am getting following logs ,
28-09-2021 11:03:38.828 org.apache.http.wire.wire - << "[\r][\n]"
28-09-2021 11:03:38.828 org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader - Receiving response: HTTP/1.1 404
28-09-2021 11:03:38.828 org.apache.http.headers.receiveResponseHeader - << HTTP/1.1 404
28-09-2021 11:03:38.829 org.apache.http.headers.receiveResponseHeader - << Server: nginx/1.14.0 (Ubuntu)
28-09-2021 11:03:38.829 org.apache.http.headers.receiveResponseHeader - << Date: Tue, 28 Sep 2021 11:03:38 GMT
28-09-2021 11:03:38.829 org.apache.http.headers.receiveResponseHeader - << Content-Type: application/xml
28-09-2021 11:03:38.829 org.apache.http.headers.receiveResponseHeader - << Content-Length: 0
28-09-2021 11:03:38.829 org.apache.http.headers.receiveResponseHeader - << Connection: keep-alive
28-09-2021 11:03:38.829 org.apache.http.impl.client.DefaultHttpClient.execute - Connection can be kept alive indefinitely
28-09-2021 11:03:38.829 com.netflix.discovery.shared.MonitoredConnectionManager.releaseConnection - Released connection is reusable.
28-09-2021 11:03:38.830 com.netflix.discovery.shared.NamedConnectionPool.freeEntry - Releasing connection [{s}->https://dev-eureka.myapp.com:443][null]
28-09-2021 11:03:38.830 com.netflix.discovery.shared.NamedConnectionPool.freeEntry - Pooling connection [{s}->https://dev-eureka.myapp.com:443][null]; keep alive indefinitely
28-09-2021 11:03:38.830 com.netflix.discovery.shared.NamedConnectionPool.notifyWaitingThread - Notifying no-one, there are no waiting threads
28-09-2021 11:03:38.830 com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.cancel - Jersey HTTP DELETE https://dev-eureka.myapp.com/eureka//apps/my-microservice/MY-APP:50c9e928d934dbdeb4abfecc1a8b9ef1; statusCode=404
28-09-2021 11:03:38.830 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.unregister - DiscoveryClient_my-microservice/MY-APP:50c9e928d934dbdeb4abfecc1a8b9ef1 - deregister status: 404
28-09-2021 11:03:39.030 com.netflix.discovery.shared.MonitoredConnectionManager.closeIdleConnections - Closing connections idle longer than 0 SECONDS
28-09-2021 11:03:39.055 com.netflix.discovery.shared.NamedConnectionPool.closeIdleConnections - Closing connections idle longer than 0 SECONDS
28-09-2021 11:03:39.056 com.netflix.discovery.shared.NamedConnectionPool.closeIdleConnections - Closing connection last used @ Tue Sep 28 11:03:38 GMT 2021
28-09-2021 11:03:39.056 com.netflix.discovery.shared.NamedConnectionPool.deleteEntry - Deleting connection [{s}->https://dev-eureka.myapp.com:443][null]
28-09-2021 11:03:39.056 org.apache.http.impl.conn.DefaultClientConnection.close - Connection 0.0.0.0:59650<->IP:443 closed
28-09-2021 11:03:39.080 com.netflix.discovery.shared.MonitoredConnectionManager.shutdown - Shutting down
28-09-2021 11:03:39.228 [SpringContextShutdownHook] INFO com.netflix.discovery.DiscoveryClient.shutdown - Completed shut down of DiscoveryClient
28-09-2021 11:03:39.228 [SpringContextShutdownHook] TRACE org.springframework.beans.factory.support.DefaultListableBeanFactory.destroyBean - Retrieved dependent beans for bean 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory': [org.springframework.context.annotation.internalConfigurationAnnotationProcessor]
Update 1: main class
@EnableDiscoveryClient
@SpringBootApplication
@FeignClient(name = "myapp")
@RibbonClient(name = "myapp")
public class CreateUserServiceApplication {
private static final Logger LOG = LogManager.getFormatterLogger();
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
/* returning object of RestTemplate */
return new RestTemplate();
}
public static void main(String[] args) {
/* APPLICATION START-UP */
String logID = RandomNumberGenerator.generateRandomNumberForLOG();
long startTime = System.currentTimeMillis();
/* declaring objects */
SpringApplication application = null;
ApplicationContext appCnt = null;
try {
/* ============= BUSINESS LOGIC ================= */
System.setProperty("spring.devtools.restart.enabled", "false");
/* defining application class */
application = new SpringApplication(CreateUserServiceApplication.class);
/*-----RUN APPLICATION-------------*/
appCnt = SpringApplication.run(CreateUserServiceApplication.class, args);
//setHibernateConfig(logID);
/* setting properties into application */
Map<String, Object> appProperties = setApplicationConstant(appCnt);
Configuration.setPropertyValue(appProperties);
application.setDefaultProperties(appProperties);
createSessionOfDatabase(logID);
} catch (Exception e) {
ExceptionLogger.logException(e, logID);
}
/* timer variable */
long endTime = System.currentTimeMillis();
}
}
bootstrap.yaml
server:
port:8080
eureka:
instance:
instanceId: ${spring.application.name}:${random.value}
##instanceId: controller:${random.value}
## this should not be enabled on production
leaseRenewalIntervalInSeconds: 1
leaseExpirationDurationInSeconds: 2
##hostname: ${host.name}
client:
serviceUrl:
defaultZone: ${server.ip}
eureka.client.healthcheck.enabled: true
lease:duration: 1
spring.cloud.config.uri: http://IP:PORT
spring.application.name: SERVICE_NAME
host:
name: ${createUser.host.name}
logging:
config: configuration/logback.xml
management:
endpoint:
refresh:
enabled: true
I have referred link1 and link2 but none of them resolved the issue. Can anyone help me out in this?