Compare commits
No commits in common. "de9219cf56e8312f046f310d749478660adf88d4" and "fefde969db678586fc9b77efe0ffea7f71c878ce" have entirely different histories.
de9219cf56
...
fefde969db
@ -10,16 +10,12 @@ import org.springframework.batch.core.explore.JobExplorer;
|
|||||||
import org.springframework.batch.core.launch.JobLauncher;
|
import org.springframework.batch.core.launch.JobLauncher;
|
||||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
|
||||||
import org.springframework.batch.core.repository.JobRepository;
|
|
||||||
import org.springframework.batch.core.repository.JobRestartException;
|
import org.springframework.batch.core.repository.JobRestartException;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.context.event.EventListener;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -29,7 +25,6 @@ public class JobLauncherController {
|
|||||||
|
|
||||||
private final JobLauncher jobLauncher;
|
private final JobLauncher jobLauncher;
|
||||||
private final JobExplorer jobExplorer;
|
private final JobExplorer jobExplorer;
|
||||||
private final JobRepository jobRepository; // 생성자 주입을 위해 필드 추가
|
|
||||||
|
|
||||||
@Value("${qsp.master-admin-user-batch-url}")
|
@Value("${qsp.master-admin-user-batch-url}")
|
||||||
private String qspInterfaceUrl;
|
private String qspInterfaceUrl;
|
||||||
@ -37,26 +32,6 @@ public class JobLauncherController {
|
|||||||
@Value("${spring.profiles.scheduler}")
|
@Value("${spring.profiles.scheduler}")
|
||||||
private String scheduler;
|
private String scheduler;
|
||||||
|
|
||||||
/**
|
|
||||||
* 서버 시작 시 실행 중(STARTED)인 상태로 남은 Job들을 FAILED 처리
|
|
||||||
*/
|
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
|
||||||
public void resetFailedJobs() {
|
|
||||||
log.info("Checking for 'STARTED' jobs to reset after reboot...");
|
|
||||||
for (String jobName : jobs.keySet()) {
|
|
||||||
Set<JobExecution> runningExecutions = jobExplorer.findRunningJobExecutions(jobName);
|
|
||||||
for (JobExecution execution : runningExecutions) {
|
|
||||||
execution.setStatus(BatchStatus.FAILED);
|
|
||||||
execution.setExitStatus(ExitStatus.FAILED.addExitDescription("Reset on application startup"));
|
|
||||||
execution.setEndTime(LocalDateTime.now()); // new Date() 대신 LocalDateTime.now() 사용
|
|
||||||
jobRepository.update(execution);
|
|
||||||
log.info("Reset job execution {} for job {}", execution.getId(), jobName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 특정 Job을 매핑으로 실행하는 메소드
|
* 특정 Job을 매핑으로 실행하는 메소드
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user