Skip to content

Commit a863a01

Browse files
authored
Merge pull request #178 from kookmin-sw/backend/develop/v3
Backend/develop/v3
2 parents 92a032d + 4f05f7e commit a863a01

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/config/SchedulerConfiguration.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public void run() {
3636
}
3737

3838
// 매 한시간마다 분석요청
39-
@Scheduled(cron = "0 0 * * * *")
40-
public void run2() {
41-
log.info("Analysis Scheduler is running");
42-
try {
43-
// 만약 분석중인 카드뷰가 하나라도 있는 경우
44-
if (!cardViewRepository.findAllByRecordFileStatusIn(List.of("WAIT")).isEmpty()) {
45-
cardViewService.getIncompleteCardViews();
46-
}
47-
48-
} catch (Exception e) {
49-
log.error("Failed to send notification");
50-
}
51-
}
39+
// @Scheduled(cron = "0 0 * * * *")
40+
// public void run2() {
41+
// log.info("Analysis Scheduler is running");
42+
// try {
43+
// // 만약 분석중인 카드뷰가 하나라도 있는 경우
44+
// if (!cardViewRepository.findAllByRecordFileStatusIn(List.of("WAIT")).isEmpty()) {
45+
// cardViewService.getIncompleteCardViews();
46+
// }
47+
//
48+
// } catch (Exception e) {
49+
// log.error("Failed to send notification");
50+
// }
51+
// }
5252
}

backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/CardViewService.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public class CardViewService {
3838

3939
public SchedulerResponseDTO.AIModelRunResponseDTO getIncompleteCardViews() throws InterruptedException {
4040
// ec2가 켜져있는지 확인
41-
if (awsService.isEc2Running()){
42-
throw new RuntimeException("EC2 is already running");
43-
}
44-
awsService.turnOnOrOff("moment-ai-t4", true);
41+
// if (awsService.isEc2Running()){
42+
// throw new RuntimeException("EC2 is already running");
43+
// }
44+
// awsService.turnOnOrOff("moment-ai-t4", true);
4545
log.info("EC2 trying to turn on");
4646
while (!awsService.isEc2Running()){
4747
log.info("sleep");
@@ -50,7 +50,7 @@ public SchedulerResponseDTO.AIModelRunResponseDTO getIncompleteCardViews() throw
5050
// 분석 완료 카드뷰 개수를 유저별로 저장
5151
Map<User, Integer> userCardViewCount = new HashMap<>();
5252

53-
sleep(31000);
53+
// sleep(31000);
5454
// 경과 시간 체크를 위한 시작 시간
5555
long startTime = System.currentTimeMillis();
5656
List<CardView> cards = cardViewRepository.findAllByRecordFileStatusIn(List.of("WAIT"));
@@ -115,16 +115,16 @@ public SchedulerResponseDTO.AIModelRunResponseDTO getIncompleteCardViews() throw
115115
}
116116
long endTime = System.currentTimeMillis();
117117
log.info("AI model run time : " + (endTime - startTime) + "ms");
118-
awsService.turnOnOrOff("moment-ai-t4", false);
118+
// awsService.turnOnOrOff("moment-ai-t4", false);
119119

120120
// 분석한만큼 유저에게 알림을 전송
121121
for (User user : userCardViewCount.keySet()){
122122
notiService.sendFinishNoti(user, userCardViewCount.get(user));
123123
}
124124

125-
while (awsService.isEc2Running()){
126-
sleep(5000);
127-
}
125+
// while (awsService.isEc2Running()){
126+
// sleep(5000);
127+
// }
128128
return SchedulerResponseDTO.AIModelRunResponseDTO.builder()
129129
.failRecordNum(failRecordNum)
130130
.successRecordNum(successRecordNum)

backend/moment/moment-server/scheduler/src/main/java/com/moment/scheduler/service/NotiService.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,19 @@ public void sendQuestionNoti(User user, String question) {
8787
log.error("Failed to send notification to user {}", user.getId());
8888
}
8989
}
90-
}
91-
try {
92-
ResponseEntity<Integer> ret = notiClient.pushMessage(
93-
FcmSendDto.builder()
94-
.token(user.getFirebaseToken())
95-
.title("moment")
96-
.body(question)
97-
.build()
98-
);
99-
log.info("Notification sent to user {} with response {}", user.getId(), ret);
100-
} catch (Exception e){
101-
log.error("Failed to send notification to user {}", user.getId());
90+
}else{
91+
try {
92+
ResponseEntity<Integer> ret = notiClient.pushMessage(
93+
FcmSendDto.builder()
94+
.token(user.getFirebaseToken())
95+
.title("moment")
96+
.body(question)
97+
.build()
98+
);
99+
log.info("Notification sent to user {} with response {}", user.getId(), ret);
100+
} catch (Exception e){
101+
log.error("Failed to send notification to user {}", user.getId());
102+
}
102103
}
103104
}
104105

0 commit comments

Comments
 (0)