1. 업데이트 개발서버 sftp 분기처리 (디렉토리 다르게 설정)
2. xml 폴링 맵핑값 수정
master
Kurt92 5 months ago
parent 2bf5d780a0
commit 1a37872e8a

@ -124,6 +124,7 @@ public class DbPolling {
// CpAnswer
cpAnswerList.add(CpAnswer.builder()
.asMmcode(String.valueOf(maxMmCode + i))
.asBbsNo(xml.getCivil_no_c().substring(xml.getCivil_no_c().lastIndexOf("_") + 1))
.asJsno(xml.getPeti_no_c())
.asJsnoM(xml.getCivil_no_c())
.asLimitDt(DateTimePatternEnum.DATE_YYYYMMDD.extractFirst(xml.getPeti_end_d()))

@ -2,6 +2,7 @@ package com.worker.scheduler.update.schedule;
import com.jcraft.jsch.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -13,6 +14,10 @@ import java.util.Properties;
@Component
public class WarSyncScheduler {
@Value("${spring.profiles.active:default}")
private String activeProfile;
// OS 확인
private final String os = System.getProperty("os.name").toLowerCase();
private final boolean isWindows = os.contains("win");
@ -23,6 +28,7 @@ public class WarSyncScheduler {
private final String SFTP_USER = "cc-war";
private final String SFTP_PASS = "xit5811807!";
private final String REMOTE_CC_WAR_PATH = "/deploy/clean-parking-boot.war";
private final String REMOTE_CC_WAR_DEV_PATH = "/dev/clean-parking-boot.war";
// 동적 드라이브 감지
private Path resolveBasePath() {
@ -69,7 +75,13 @@ public class WarSyncScheduler {
log.info("[배포] SFTP 업테이트 서버 연결 성공");
// 리모트 파일 속성
SftpATTRS attrs = sftp.lstat(REMOTE_CC_WAR_PATH);
// todo : 데브환경 분기처리
SftpATTRS attrs = null;
if(activeProfile.equals("prod")){
sftp.lstat(REMOTE_CC_WAR_PATH);
} else {
sftp.lstat(REMOTE_CC_WAR_DEV_PATH);
}
long remoteSize = attrs.getSize();
int remoteMtime = attrs.getMTime();
@ -92,6 +104,9 @@ public class WarSyncScheduler {
killPreviousWar();
log.info("[배포] 프로세스 kill");
// 킬하고 기존에 war를 백업으로 이동해야함
// 롤백을 위함.
// 교체
Files.move(LOCAL_TMP_PATH, LOCAL_WAR_PATH, StandardCopyOption.REPLACE_EXISTING);
log.info("[배포] WAR 파일 교체 완료");
@ -113,6 +128,7 @@ public class WarSyncScheduler {
}
}
// 변경 체크 (파일 사이즈, 수정시간)
private boolean isWarUpdated(long remoteSize, int remoteMtime) throws IOException {
if (!Files.exists(META_FILE_PATH)) return true;
@ -123,6 +139,7 @@ public class WarSyncScheduler {
return (remoteSize != prevSize || remoteMtime != prevMtime);
}
//기존 프로세스 kill
private void killPreviousWar() {
try {
if (!Files.exists(PID_FILE_PATH)) return;
@ -140,6 +157,7 @@ public class WarSyncScheduler {
}
}
// -jar 로 실행
private void runWar() throws IOException {
ProcessBuilder pb = new ProcessBuilder("java", "-jar", LOCAL_WAR_PATH.toString());
pb.directory(LOCAL_WAR_PATH.getParent().toFile());

Loading…
Cancel
Save