Skip to content

Commit

Permalink
feat: SIGTERM 신호를 수신하였다는 메세지를 출력하도록 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
joon6093 committed Nov 29, 2024
1 parent 6efe566 commit 6a65e7d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package io.jeyong.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.misc.SignalHandler;

public abstract class ApplicationTerminator {

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

private final String terminationMessagePath;
private final String terminationMessage;

Expand All @@ -14,6 +18,7 @@ protected ApplicationTerminator(final String terminationMessagePath, final Strin

public SignalHandler handleTermination() {
return signal -> {
logger.info("Received SIGTERM signal. Initiating termination handler.");
FileUtils.writeToFile(terminationMessagePath, terminationMessage);
System.exit(getExitCode());
};
Expand Down

0 comments on commit 6a65e7d

Please sign in to comment.