From 4d513639ac8e348bdc5d1c7effe482fda4904ea9 Mon Sep 17 00:00:00 2001 From: "icksishu@gmail.com" Date: Thu, 16 Oct 2025 13:10:51 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A2=85=EB=A3=8C=EB=AA=85=EB=A0=B9=EC=96=B4?= =?UTF-8?q?=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../config/DfxAgentShutdownEndpoint.java | 48 +++++++++++++++++++ src/main/resources/application.yml | 8 ++++ 3 files changed, 57 insertions(+) create mode 100644 src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java diff --git a/build.gradle b/build.gradle index a1f632c..e512334 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-jdbc' implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.4' compileOnly 'org.projectlombok:lombok' implementation 'com.h2database:h2' diff --git a/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java b/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java new file mode 100644 index 0000000..fc40c77 --- /dev/null +++ b/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java @@ -0,0 +1,48 @@ +package com.bsmlab.dfx.agent.config; + +import lombok.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; +import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Endpoint(id = "shutdown") +@Component +@RequiredArgsConstructor +@Slf4j +public class DfxAgentShutdownEndpoint { + private final ApplicationContext applicationContext; + + @Data + @Builder + @AllArgsConstructor + @NoArgsConstructor + public static class DfxAgentShutdownRequestDto { + private String comment; + private int exitCode; + private int delaySeconds; + private int forceAfterSeconds; + } + + /** + * # 지연 3초 후 종료, 15초 후 강제 종료(백업), exitCode=0 + * curl -X POST http://localhost:8080/actuator/shutdown \ + * -H "Content-Type: application/json" \ + * -d '{ + * "comment":"배포하기 위해 종료", + * "exitCode":0, + * "delaySeconds":3, + * "forceAfterSeconds":15 + * }' + * @param body + * @return + */ + @WriteOperation // Actuator 엔드포인트는 @WriteOperation 으로 POST 요청을 수신함. @ReadOperation GET 요청 수신 + public Map shutdown(DfxAgentShutdownRequestDto body) { + + return null; + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9c48849..76c0eda 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,6 +7,14 @@ spring: multipart: max-file-size: 1GB max-request-size: 1GB +management: + endpoints: + web: + exposure: + include: shutdown + endpoint: + shutdown: + enabled: true logging: level: root: ERROR