From 5de747008e484e4e117a71f25e721bb2b9aea4df Mon Sep 17 00:00:00 2001 From: "icksishu@gmail.com" Date: Fri, 28 Nov 2025 15:51:20 +0900 Subject: [PATCH] =?UTF-8?q?shutdown=20endpoint=20=EC=88=98=EC=8B=A0?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=EB=A7=8C=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conf/dfxagent-bsm-lab-postgres.json | 12 +++---- .../config/DfxAgentShutdownEndpoint.java | 32 +++++++++++-------- src/main/resources/application.yml | 5 ++- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/docs/agent-bsm-lab-postgres/conf/dfxagent-bsm-lab-postgres.json b/src/docs/agent-bsm-lab-postgres/conf/dfxagent-bsm-lab-postgres.json index e7824bd..03bf412 100644 --- a/src/docs/agent-bsm-lab-postgres/conf/dfxagent-bsm-lab-postgres.json +++ b/src/docs/agent-bsm-lab-postgres/conf/dfxagent-bsm-lab-postgres.json @@ -35,10 +35,10 @@ } ], "sqlMapperLocations": [ - "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/conf/mappers/**/*.xml" + "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/conf/mappers/**/*.xml" ], "logging": { - "logDirectory": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/logs", + "logDirectory": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/logs", "logFileName": "dfxagent.log", "logName": "DFX_LOG", "maxHistory": 30, @@ -59,10 +59,10 @@ ] }, "dropBoxConfig": { - "receivedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/messages/received", - "processedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/messages/processed", - "failureMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/messages/failure", - "manualMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-tuf-a15-defree-oracle/messages/manual", + "receivedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/messages/received", + "processedMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/aagent-bsm-lab-postgres/messages/processed", + "failureMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/messages/failure", + "manualMessageStorageRoot": "D:/projects/bsm-lab/dfx/dfxagent/src/docs/agent-bsm-lab-postgres/messages/manual", "threadPoolSize": 300, "retentionDaysOfProcessedMessage": 60, "dropBoxList": [ diff --git a/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java b/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java index fc40c77..6af80e3 100644 --- a/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java +++ b/src/main/java/com/bsmlab/dfx/agent/config/DfxAgentShutdownEndpoint.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; import java.util.Map; -@Endpoint(id = "shutdown") +@Endpoint(id = "dfxagentShutdown") @Component @RequiredArgsConstructor @Slf4j @@ -20,6 +20,7 @@ public class DfxAgentShutdownEndpoint { @Builder @AllArgsConstructor @NoArgsConstructor + @ToString public static class DfxAgentShutdownRequestDto { private String comment; private int exitCode; @@ -29,20 +30,23 @@ public class DfxAgentShutdownEndpoint { /** * # 지연 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 + * curl -X POST "http://localhost:63801/actuator/dfxagentShutdown" -H "Content-Type: application/json" -H "User-Agent: DFXConsole" -d "{\"comment\":\"배포하기 위해 종료\",\"exitCode\":0,\"delaySeconds\":3,\"forceAfterSeconds\":15}" + * @param comment 예) "배포하기 위해 종료" + * @param exitCode 0은 정상 종료 9는 강제 종료 + * @param delaySeconds 종료 실행 전 기다리는 시간(초) + * @param forceAfterSeconds 강제 종료 전 기다리는 시간(초) + * @return {@return } */ @WriteOperation // Actuator 엔드포인트는 @WriteOperation 으로 POST 요청을 수신함. @ReadOperation GET 요청 수신 - public Map shutdown(DfxAgentShutdownRequestDto body) { - - return null; + public Map shutdown(String comment, int exitCode, int delaySeconds, int forceAfterSeconds) { + Map receivedData = Map.of( + "status", "SHUTDOWN_SCHEDULED", + "comment", comment, + "exitCode", exitCode, + "delaySeconds", delaySeconds, + "forceAfterSeconds", forceAfterSeconds + ); + log.debug("{}", receivedData); + return receivedData; } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 64354b0..2fdaddd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,7 +15,10 @@ management: exclude: '*' web: exposure: - include: shutdown + include: dfxagentshutdown + endpoint: + dfxagentShutdown: + enabled: true logging: level: root: ERROR