Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

downscale gracefully #647

Merged
merged 12 commits into from
Jul 3, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import io.micrometer.core.instrument.MeterRegistry;
import java.util.Arrays;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
Expand All @@ -46,7 +48,7 @@
"app.coronawarn.server.services.submission"})
@EnableConfigurationProperties
@EnableFeignClients
public class ServerApplication implements EnvironmentAware {
public class ServerApplication implements EnvironmentAware, DisposableBean {

private static final Logger logger = LoggerFactory.getLogger(ServerApplication.class);

Expand All @@ -59,6 +61,14 @@ TimedAspect timedAspect(MeterRegistry registry) {
return new TimedAspect(registry);
}

/**
* Manual shutdown hook needed to avoid Log4j shutdown issues (see cwa-server/#589).
*/
@Override
public void destroy() {
LogManager.shutdown();
hilmarf marked this conversation as resolved.
Show resolved Hide resolved
}

@Bean
ProtobufHttpMessageConverter protobufHttpMessageConverter() {
return new ProtobufHttpMessageConverter();
Expand Down
5 changes: 5 additions & 0 deletions services/submission/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ services:
trust-store-password: ${SSL_VERIFICATION_TRUSTSTORE_PASSWORD}

spring:
lifecycle:
# keep in sync or lower than the kubernetes setting 'terminationGracePeriodSeconds'
# 5s +5s Feign client + 20s DB timeout
timeout-per-shutdown-phase: 30s
transaction:
default-timeout: 20
flyway:
Expand Down Expand Up @@ -82,6 +86,7 @@ management:
enabled: true

server:
shutdown: graceful
ssl:
enabled: true
enabled-protocols: TLSv1.2,TLSv1.3
Expand Down