Skip to content

Commit

Permalink
feat: 라이브러리 사용 시 초기화 메세지를 통해 설정 정보를 출력하도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
joon6093 committed Nov 29, 2024
1 parent 2a05115 commit 6efe566
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.jeyong.handler;

import jakarta.annotation.PostConstruct;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
Expand All @@ -16,6 +20,7 @@
@EnableConfigurationProperties(SigtermHandlerProperties.class)
public class SigtermHandlerConfiguration {

private static final Logger logger = LoggerFactory.getLogger(SigtermHandlerConfiguration.class);
private static final String SIGNAL_TYPE = "TERM";

private final SigtermHandlerProperties sigtermHandlerProperties;
Expand All @@ -24,6 +29,19 @@ public SigtermHandlerConfiguration(final SigtermHandlerProperties sigtermHandler
this.sigtermHandlerProperties = sigtermHandlerProperties;
}

@PostConstruct
public void logInitialization() {
if (Strings.isBlank(sigtermHandlerProperties.getTerminationMessagePath())) {
logger.info("Sigterm handler initialized with exitCode: {}", sigtermHandlerProperties.getExitCode());
} else {
logger.info(
"Sigterm handler initialized with exitCode: {}, terminationMessagePath: {}, terminationMessage: '{}'",
sigtermHandlerProperties.getExitCode(),
sigtermHandlerProperties.getTerminationMessagePath(),
sigtermHandlerProperties.getTerminationMessage());
}
}

@Bean
public ApplicationTerminator applicationTerminator(final ApplicationContext applicationContext) {
return new SpringContextTerminator(applicationContext, sigtermHandlerProperties.getExitCode(),
Expand Down

0 comments on commit 6efe566

Please sign in to comment.