diff --git a/bin/roadrunner-worker.php b/bin/roadrunner-worker.php index 7d65f250..c4a89a85 100644 --- a/bin/roadrunner-worker.php +++ b/bin/roadrunner-worker.php @@ -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 { diff --git a/composer.json b/composer.json index 0380442f..0028e27f 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php index dbc553f1..657caffb 100644 --- a/config/autoload/dependencies.global.php +++ b/config/autoload/dependencies.global.php @@ -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, + ], + ], + ]; diff --git a/config/roadrunner/.rr.dev.yml b/config/roadrunner/.rr.dev.yml index 4136f195..23e9679f 100644 --- a/config/roadrunner/.rr.dev.yml +++ b/config/roadrunner/.rr.dev.yml @@ -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