Merge pull request '두 인스턴스가 데이터베이스를 통해 실제 job 실행 상태를 정확히 확인가능 변' (#196) from dev into prd-deploy
Reviewed-on: #196
This commit is contained in:
commit
3e91ebe0b7
@ -32,8 +32,6 @@ public class JobLauncherController {
|
|||||||
@Value("${spring.profiles.scheduler}")
|
@Value("${spring.profiles.scheduler}")
|
||||||
private String scheduler;
|
private String scheduler;
|
||||||
|
|
||||||
// 현재 실행 중인 Job 추적을 위한 Set
|
|
||||||
private final Set<String> runningJobs = ConcurrentHashMap.newKeySet();
|
|
||||||
/**
|
/**
|
||||||
* 특정 Job을 매핑으로 실행하는 메소드
|
* 특정 Job을 매핑으로 실행하는 메소드
|
||||||
*
|
*
|
||||||
@ -59,31 +57,35 @@ public class JobLauncherController {
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 실행 중인 Job 확인
|
// 실행 중인 Job 확인 (데이터베이스 기반)
|
||||||
if (runningJobs.contains(jobName) || isJobRunning(jobName)) {
|
if (isJobRunning(jobName)) {
|
||||||
log.warn("Job {} is already running, skipping execution", jobName);
|
log.warn("Job {} is already running, skipping execution", jobName);
|
||||||
resultMap.put("code", "FAILED");
|
resultMap.put("code", "FAILED");
|
||||||
resultMap.put("message", "Job "+ jobName +" is already running, skipping execution");
|
resultMap.put("message", "Job "+ jobName +" is already running, skipping execution");
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.info("Starting job: {}", jobName);
|
||||||
|
|
||||||
JobParameters jobParameters = new JobParametersBuilder().addString("jobName", jobName)
|
JobParameters jobParameters = new JobParametersBuilder().addString("jobName", jobName)
|
||||||
.addDate("time", new Date()).toJobParameters();
|
.addDate("time", new Date()).toJobParameters();
|
||||||
|
|
||||||
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
|
JobExecution jobExecution = jobLauncher.run(job, jobParameters);
|
||||||
|
|
||||||
|
BatchStatus status = jobExecution.getStatus();
|
||||||
|
ExitStatus exitStatus = jobExecution.getExitStatus();
|
||||||
|
|
||||||
|
resultMap.put("code", status.toString());
|
||||||
|
resultMap.put("message", exitStatus.getExitDescription());
|
||||||
|
|
||||||
BatchStatus status = jobExecution.getStatus();
|
// return "Job " + jobName + " started";
|
||||||
ExitStatus exitStatus = jobExecution.getExitStatus();
|
return resultMap;
|
||||||
|
} catch (Exception e) {
|
||||||
resultMap.put("code", status.toString());
|
resultMap.put("code", "FAILED");
|
||||||
resultMap.put("message", exitStatus.getExitDescription());
|
resultMap.put("message", e.getMessage());
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
// return "Job " + jobName + " started";
|
|
||||||
return resultMap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,8 +225,8 @@ public class JobLauncherController {
|
|||||||
return "Scheduler disabled";
|
return "Scheduler disabled";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 실행 중인 Job 확인
|
// 실행 중인 Job 확인 (데이터베이스 기반)
|
||||||
if (runningJobs.contains(jobName) || isJobRunning(jobName)) {
|
if (isJobRunning(jobName)) {
|
||||||
log.warn("Job {} is already running, skipping execution", jobName);
|
log.warn("Job {} is already running, skipping execution", jobName);
|
||||||
return "Job already running";
|
return "Job already running";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user