-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Runner.php
40 lines (29 loc) · 968 Bytes
/
Runner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
namespace Baldinof\RoadRunnerBundle\Runtime;
use Baldinof\RoadRunnerBundle\Worker\WorkerRegistryInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Runtime\RunnerInterface;
class Runner implements RunnerInterface
{
private KernelInterface $kernel;
private string $mode;
public function __construct(KernelInterface $kernel, string $mode)
{
$this->kernel = $kernel;
$this->mode = $mode;
}
public function run(): int
{
$this->kernel->boot();
/** @var WorkerRegistryInterface $registry */
$registry = $this->kernel->getContainer()->get(WorkerRegistryInterface::class);
$worker = $registry->getWorker($this->mode);
if (null === $worker) {
error_log(sprintf('Missing RR worker implementation for %s mode', $this->mode));
return 1;
}
$worker->start();
return 0;
}
}