Starttime by reference

This commit is contained in:
Jeroen De Meerleer 2021-05-29 11:56:29 +02:00
parent cb848f0bfa
commit 94c2cfc48c
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 28CCCB8F62BFADD6
1 changed files with 4 additions and 6 deletions

View File

@ -174,7 +174,7 @@ class Job extends Repository
return $return; return $return;
} }
private function runRebootJob(array $job, float $starttime): array private function runRebootJob(array $job, float &$starttime): array
{ {
if($job['running'] == 1) { if($job['running'] == 1) {
$this->setTempVar($job['id'], 'starttime', $starttime); $this->setTempVar($job['id'], 'starttime', $starttime);
@ -203,6 +203,9 @@ class Job extends Repository
if($job['running'] > time()) { if($job['running'] > time()) {
exit; exit;
} }
$starttime = (float)$this->getTempVar($job['id'], 'starttime');
$this->deleteTempVar($job['id'], 'starttime');
$jobsSql = "UPDATE job SET running = :status WHERE id = :id"; $jobsSql = "UPDATE job SET running = :status WHERE id = :id";
$jobsStmt = $this->dbcon->prepare($jobsSql); $jobsStmt = $this->dbcon->prepare($jobsSql);
$jobsStmt->executeQuery([':id' => $job['id'], ':status' => 1]); $jobsStmt->executeQuery([':id' => $job['id'], ':status' => 1]);
@ -218,10 +221,6 @@ class Job extends Repository
$return = $this->runLocalCommand($job['data']['getservices-command']); $return = $this->runLocalCommand($job['data']['getservices-command']);
} }
$starttime = (float)$this->getTempVar($job['id'], 'starttime');
$this->deleteTempVar($job['id'], 'starttime');
$return['starttime'] = $starttime;
return $return; return $return;
} }
} }
@ -244,7 +243,6 @@ class Job extends Repository
$result = $this->runCommandJob($job); $result = $this->runCommandJob($job);
} elseif($job['data']['crontype'] == 'reboot') { } elseif($job['data']['crontype'] == 'reboot') {
$result = $this->runRebootJob($job, $starttime); $result = $this->runRebootJob($job, $starttime);
$starttime = $result['starttime'];
} }
$endtime = microtime(true); $endtime = microtime(true);
$runtime = $endtime - $starttime; $runtime = $endtime - $starttime;