Skip to content

Commit 4c873af

Browse files
committed
[Feat] spring warm-up
1 parent e127915 commit 4c873af

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

src/main/java/com/example/Jinus/service/WarmUpService.java

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import org.slf4j.LoggerFactory;
55
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
66
import org.springframework.context.event.ContextRefreshedEvent;
7+
import org.springframework.http.HttpEntity;
8+
import org.springframework.http.HttpHeaders;
9+
import org.springframework.http.MediaType;
710
import org.springframework.http.ResponseEntity;
811
import org.springframework.scheduling.annotation.Scheduled;
912
import org.springframework.stereotype.Component;
@@ -61,7 +64,58 @@ public void warmUpEndpoints() {
6164
String url = baseUrl + pattern;
6265
try {
6366
logger.debug("Warming up endpoint: {} {}", RequestMethod.POST, url);
64-
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
67+
// POST 요청을 위한 빈 요청 본문 생성
68+
HttpHeaders headers = new HttpHeaders();
69+
headers.setContentType(MediaType.APPLICATION_JSON);
70+
71+
String requestBody = """
72+
{
73+
"intent": {
74+
"id": "yvm1dtgi7nym54z0aaid71pl",
75+
"name": "블록 이름"
76+
},
77+
"userRequest": {
78+
"timezone": "Asia/Seoul",
79+
"params": {
80+
"ignoreMe": "true"
81+
},
82+
"block": {
83+
"id": "yvm1dtgi7nym54z0aaid71pl",
84+
"name": "블록 이름"
85+
},
86+
"utterance": "발화 내용",
87+
"lang": null,
88+
"user": {
89+
"id": "74f7e7ab2bf19e63bb1ec845b760631259d7615440a2d3db7b344ac48ed1bbcde5",
90+
"type": "accountId",
91+
"properties": {}
92+
}
93+
},
94+
"bot": {
95+
"id": "65e8142d0a73415ce0694943",
96+
"name": "봇 이름"
97+
},
98+
"action": {
99+
"name": "g7e6t8yqcr",
100+
"clientExtra": {
101+
"sys_campus_id": "1"
102+
},
103+
"params": {
104+
"sys_date": "오늘",
105+
"sys_cafeteria_name": "아람관"
106+
},
107+
"id": "yvy3cqsh14brsvm9uf55cktv",
108+
"detailParams": {
109+
"sys_cafeteria_name": {
110+
"origin": "아람관"
111+
}
112+
}
113+
}
114+
}""";
115+
116+
HttpEntity<String> request = new HttpEntity<>(requestBody, headers);
117+
118+
ResponseEntity<String> response = restTemplate.postForEntity(url, request, String.class);
65119
logger.debug("Warm-up response status: {}", response.getStatusCode());
66120
} catch (Exception e) {
67121
logger.warn("Failed to warm up endpoint: {} - {}", url, e.getMessage());

0 commit comments

Comments
 (0)