From 12205ad18e2c8035c89b2668a0b776b4075d4ccd Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Wed, 11 Jan 2023 13:46:19 +0100 Subject: [PATCH] BUGFIX: reboot jobs stopped after triggering initial command --- src/Command/DaemonCommand.php | 11 ++++------- src/Repository/JobRepository.php | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Command/DaemonCommand.php b/src/Command/DaemonCommand.php index 0cdf6ca..17f544b 100644 --- a/src/Command/DaemonCommand.php +++ b/src/Command/DaemonCommand.php @@ -74,13 +74,10 @@ class DaemonCommand extends Command $jobRepo = $this->doctrine->getRepository(Job::class); } - if(!$async || $pid == -1) { - $jobRepo->RunJob($job, $manual); - $jobRepo->setJobRunning($job, false); - } elseif ($pid == 0) { - $jobRepo->RunJob($job, $manual); - $jobRepo->setJobRunning($job, false); - exit; + if((!$async || $pid == -1) || $pid == 0) { + $result = $jobRepo->RunJob($job, $manual); + if ($result['status'] == 'ran') $jobRepo->setJobRunning($job, false); + if ($pid == 0) exit; } unset($jobsToRun[$key]); unset($job); diff --git a/src/Repository/JobRepository.php b/src/Repository/JobRepository.php index 6f7d9bf..9e5fe9b 100644 --- a/src/Repository/JobRepository.php +++ b/src/Repository/JobRepository.php @@ -516,7 +516,7 @@ class JobRepository extends EntityRepository $this->deleteTempVar($job); $em->persist($job); $em->flush(); - return ['job_id' => $job->getId(), 'exitcode' => $result['exitcode'], 'timestamp' =>floor($starttime), 'runtime' => $runtime, 'output' => (string)$result['output'], 'flags' => implode("", $flags)]; + return ['job_id' => $job->getId(), 'status' => 'ran', 'exitcode' => $result['exitcode'], 'timestamp' =>floor($starttime), 'runtime' => $runtime, 'output' => (string)$result['output'], 'flags' => implode("", $flags)]; } /**