Skip to content

Commit

Permalink
✨ 전시회
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Yong99 committed Jun 17, 2024
1 parent 4f05f7e commit f0c1716
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ public void run() {
}
}

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

} catch (Exception e) {
log.error("Failed to send notification");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class CardViewService {

public SchedulerResponseDTO.AIModelRunResponseDTO getIncompleteCardViews() throws InterruptedException {
// ec2가 켜져있는지 확인
// if (awsService.isEc2Running()){
// throw new RuntimeException("EC2 is already running");
// }
// awsService.turnOnOrOff("moment-ai-t4", true);
if (awsService.isEc2Running()){
throw new RuntimeException("EC2 is already running");
}
awsService.turnOnOrOff("moment-ai-t4", true);
log.info("EC2 trying to turn on");
while (!awsService.isEc2Running()){
log.info("sleep");
Expand Down Expand Up @@ -115,16 +115,16 @@ public SchedulerResponseDTO.AIModelRunResponseDTO getIncompleteCardViews() throw
}
long endTime = System.currentTimeMillis();
log.info("AI model run time : " + (endTime - startTime) + "ms");
// awsService.turnOnOrOff("moment-ai-t4", false);
awsService.turnOnOrOff("moment-ai-t4", false);

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

// while (awsService.isEc2Running()){
// sleep(5000);
// }
while (awsService.isEc2Running()){
sleep(5000);
}
return SchedulerResponseDTO.AIModelRunResponseDTO.builder()
.failRecordNum(failRecordNum)
.successRecordNum(successRecordNum)
Expand Down

0 comments on commit f0c1716

Please sign in to comment.