FastCGI Command max requests

This commit is contained in:
Juan Pablo Vial
2025-06-30 17:09:45 -04:00
parent 829ab86770
commit e35053edce
3 changed files with 30 additions and 7 deletions

View File

@ -42,10 +42,7 @@ class Run extends Console\Command\Command
array_map(function($row) {return [$row];},$jobIds)
]]);
$this->pushOutput('top', ['progress' => $jobCount]);
foreach ($jobIds as $jobId) {
$this->runJob($jobId);
}
$result = $this->getResponses();
$result = $this->runJobs($jobIds);
$this->pushOutput('top', ['progress' => 'finish']);
$this->writeOutput($input, $output);
@ -53,15 +50,34 @@ class Run extends Console\Command\Command
return $result;
}
protected function runJob(int $jobId): void
protected function runJobs(array $jobIds): int
{
$pendingJobs = [];
foreach ($jobIds as $jobId) {
if (!$this->runJob($jobId)) {
$pendingJobs []= $jobId;
}
}
$result = $this->getResponses();
if (count($pendingJobs) > 0) {
if ($this->runJobs($pendingJobs) === self::FAILURE) {
$result = self::FAILURE;
}
}
return $result;
}
protected function runJob(int $jobId): bool
{
$uri = "/api/queue/run/{$jobId}";
$this->pushOutput('bottom', ['message' => "GET {$uri}"]);
try {
$this->fastcgi->get($uri);
return true;
} catch (FastCGIException $exception) {
$this->logger->error($exception->getMessage(), ['uri' => $uri, 'exception' =>$exception]);
return false;
}
}
protected function getResponses(): int