Simplified RoadRunner worker, and fixed RoadRunner reloading config

This commit is contained in:
Alejandro Celaya 2022-08-27 08:01:57 +02:00
parent 86159c5d86
commit c5b6d203f5
4 changed files with 26 additions and 14 deletions

View file

@ -4,27 +4,20 @@ declare(strict_types=1);
use Mezzio\Application;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Shlinkio\Shlink\EventDispatcher\RoadRunner\RoadRunnerTaskConsumerToListener;
use Spiral\RoadRunner\Http\PSR7Worker;
use Spiral\RoadRunner\Worker;
use function Shlinkio\Shlink\Config\env;
(static function (): void {
$rrMode = getenv('RR_MODE');
/** @var ContainerInterface $container */
$container = include __DIR__ . '/../config/container.php';
$rrMode = env('RR_MODE');
if ($rrMode === 'http') {
// This was spin-up as a web worker
$app = $container->get(Application::class);
$worker = new PSR7Worker(
Worker::create(),
$container->get(ServerRequestFactoryInterface::class),
$container->get(StreamFactoryInterface::class),
$container->get(UploadedFileFactoryInterface::class),
);
$worker = $container->get(PSR7Worker::class);
while ($req = $worker->waitRequest()) {
try {

View file

@ -45,7 +45,7 @@
"ramsey/uuid": "^4.3",
"shlinkio/shlink-common": "^5.0",
"shlinkio/shlink-config": "dev-main#24ccd64 as 2.1",
"shlinkio/shlink-event-dispatcher": "dev-main#7bf5b58 as 2.6",
"shlinkio/shlink-event-dispatcher": "dev-main#48c0137 as 2.6",
"shlinkio/shlink-importer": "^4.0",
"shlinkio/shlink-installer": "^8.1",
"shlinkio/shlink-ip-geolocation": "^3.0",

View file

@ -3,12 +3,22 @@
declare(strict_types=1);
use GuzzleHttp\Client;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Mezzio\Container;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ServerRequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UploadedFileFactoryInterface;
use Spiral\RoadRunner\Http\PSR7Worker;
use Spiral\RoadRunner\WorkerInterface;
return [
'dependencies' => [
'factories' => [
PSR7Worker::class => ConfigAbstractFactory::class,
],
'delegators' => [
Mezzio\Application::class => [
Container\ApplicationConfigInjectionDelegator::class,
@ -26,4 +36,13 @@ return [
],
],
ConfigAbstractFactory::class => [
PSR7Worker::class => [
WorkerInterface::class,
ServerRequestFactoryInterface::class,
StreamFactoryInterface::class,
UploadedFileFactoryInterface::class,
],
],
];

View file

@ -46,8 +46,8 @@ reload:
patterns: ['.php', '.yml', '.yaml']
services:
http:
dirs: ['../..']
dirs: ['../../bin', '../../config', '../../data/migrations', '../../docker', '../../module', '../../vendor']
recursive: true
jobs:
dirs: ['../..']
dirs: ['../../bin', '../../config', '../../data/migrations', '../../docker', '../../module', '../../vendor']
recursive: true