BUGFIX: guzzle does not only give request exceptions
This commit is contained in:
parent
1dc11efb6c
commit
5c3da88979
|
@ -54,7 +54,7 @@ class DaemonCommand extends Command
|
|||
$str = @file_get_contents('/proc/uptime');
|
||||
$num = floatval($str);
|
||||
$rebootedself = ($num < $jobObj['data']['reboot-duration'] * 60);
|
||||
$consolerun = $jobRepo->getTempVar($job['id'], 'consolerun');
|
||||
$consolerun = $jobRepo->getTempVar($job['id'], 'consolerun', false);
|
||||
if($consolerun && !$rebootedself) continue;
|
||||
}
|
||||
$jobRepo->setJobRunning($job['id'], true);
|
||||
|
|
|
@ -30,6 +30,7 @@ class RunCommand extends Command
|
|||
->setHelp('This command runs a single command')
|
||||
->addArgument('jobid', InputArgument::REQUIRED, 'The id of the job to be run');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$jobRepo = new Job($this->kernel->getDbCon());
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace JeroenED\Webcron\Repository;
|
|||
|
||||
use DateTime;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use JeroenED\Framework\Repository;
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
use phpseclib3\Net\SSH2;
|
||||
|
@ -114,13 +114,13 @@ class Job extends Repository
|
|||
return;
|
||||
}
|
||||
|
||||
public function getTempVar(int $job, string $name): mixed
|
||||
public function getTempVar(int $job, string $name, mixed $default = NULL): mixed
|
||||
{
|
||||
$jobsSql = "SELECT data FROM job WHERE id = :id";
|
||||
$jobsStmt = $this->dbcon->prepare($jobsSql);
|
||||
$result = $jobsStmt->executeQuery([':id' => $job])->fetchAssociative();
|
||||
$result = json_decode($result['data'], true);
|
||||
return $result['temp_vars'][$name];
|
||||
return $result['temp_vars'][$name] ?? $default;
|
||||
}
|
||||
|
||||
private function runHttpJob(array $job): array
|
||||
|
@ -142,7 +142,7 @@ class Job extends Repository
|
|||
$return['exitcode'] = $res->getStatusCode();
|
||||
$return['output'] = $res->getBody();
|
||||
$return['failed'] = !in_array($return['exitcode'], $job['data']['http-status']);
|
||||
} catch(RequestException $exception) {
|
||||
} catch(GuzzleException $exception) {
|
||||
$return['exitcode'] = $exception->getCode();
|
||||
$return['output'] = $exception->getMessage();
|
||||
$return['failed'] = true;
|
||||
|
|
Loading…
Reference in New Issue