BUGFIX: if job is running, don't run
This commit is contained in:
parent
c825dd9b7f
commit
f8c89230b7
|
@ -34,6 +34,11 @@ class RunCommand extends Command
|
|||
{
|
||||
$jobRepo = new Job($this->kernel->getDbCon());
|
||||
$jobId = (int)$input->getArgument('jobid');
|
||||
$jobRunning = $jobRepo->isLockedJob($jobId);
|
||||
if($jobRunning) {
|
||||
$output->writeln('Job is already running');
|
||||
return Command::FAILURE;
|
||||
}
|
||||
$jobRepo->setJobRunning($jobId, true);
|
||||
$jobRepo->setTempVar($jobId, 'consolerun', true);
|
||||
$result = $jobRepo->runNow($jobId, true);
|
||||
|
|
|
@ -323,6 +323,14 @@ class Job extends Repository
|
|||
return;
|
||||
}
|
||||
|
||||
public function isLockedJob(int $id = 0): bool
|
||||
{
|
||||
$jobsSql = "SELECT id FROM job WHERE id = :id AND running != :status";
|
||||
$params = [':status' => 0, ':id' => $id];
|
||||
|
||||
return count($this->dbcon->prepare($jobsSql)->executeQuery($params)->fetchAllAssociative()) > 0;
|
||||
}
|
||||
|
||||
public function addJob(array $values)
|
||||
{
|
||||
if(empty($values['crontype']) ||
|
||||
|
|
Loading…
Reference in New Issue