FastCGI Command max requests
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user