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

View file

@ -45,7 +45,7 @@
"ramsey/uuid": "^4.3", "ramsey/uuid": "^4.3",
"shlinkio/shlink-common": "^5.0", "shlinkio/shlink-common": "^5.0",
"shlinkio/shlink-config": "dev-main#24ccd64 as 2.1", "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-importer": "^4.0",
"shlinkio/shlink-installer": "^8.1", "shlinkio/shlink-installer": "^8.1",
"shlinkio/shlink-ip-geolocation": "^3.0", "shlinkio/shlink-ip-geolocation": "^3.0",

View file

@ -3,12 +3,22 @@
declare(strict_types=1); declare(strict_types=1);
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Mezzio\Container; use Mezzio\Container;
use Psr\Http\Client\ClientInterface; 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 [ return [
'dependencies' => [ 'dependencies' => [
'factories' => [
PSR7Worker::class => ConfigAbstractFactory::class,
],
'delegators' => [ 'delegators' => [
Mezzio\Application::class => [ Mezzio\Application::class => [
Container\ApplicationConfigInjectionDelegator::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'] patterns: ['.php', '.yml', '.yaml']
services: services:
http: http:
dirs: ['../..'] dirs: ['../../bin', '../../config', '../../data/migrations', '../../docker', '../../module', '../../vendor']
recursive: true recursive: true
jobs: jobs:
dirs: ['../..'] dirs: ['../../bin', '../../config', '../../data/migrations', '../../docker', '../../module', '../../vendor']
recursive: true recursive: true