diff --git a/.docker/php/Dockerfile b/.docker/php/Dockerfile index 4a0f18a9..06ec5a8a 100755 --- a/.docker/php/Dockerfile +++ b/.docker/php/Dockerfile @@ -51,6 +51,9 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends libicu-dev RUN docker-php-ext-install intl +# ROADRUNNER +RUN docker-php-ext-install sockets + #localisation file RUN rm -rf /var/lib/apt/lists/* RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ diff --git a/.gitignore b/.gitignore index a4f4ba47..93166ac5 100755 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,7 @@ composer-normalize ###> phpstan/phpstan ### phpstan.neon ###< phpstan/phpstan ### + +###> baldinof/roadrunner-bundle ### +/bin/rr +###< baldinof/roadrunner-bundle ### diff --git a/.rr.dev.yaml b/.rr.dev.yaml new file mode 100644 index 00000000..2ea41b1f --- /dev/null +++ b/.rr.dev.yaml @@ -0,0 +1,32 @@ +version: "3" + +server: + command: "php public/index.php" + env: + - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime + +http: + address: 0.0.0.0:8080 + ssl: + address: :443 + cert: certs/draw.com.crt + key: certs/draw.com.key + pool: + debug: true + middleware: [ "static", "gzip" ] + uploads: + forbid: [ ".php", ".exe", ".bat" ] + static: + dir: "public" + forbid: [ ".php", ".htaccess" ] + +logs: + mode: development + channels: + http: + level: debug # Log all http requests, set to info to disable + server: + level: info # Everything written to worker stderr is logged + mode: raw + metrics: + level: debug diff --git a/.rr.yaml b/.rr.yaml new file mode 100644 index 00000000..a3a77527 --- /dev/null +++ b/.rr.yaml @@ -0,0 +1,37 @@ +version: "3" + +server: + command: "php public/index.php" + env: + - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime + +http: + address: 0.0.0.0:8080 + pool: + debug: false + middleware: [ "static", "gzip" ] + uploads: + forbid: [ ".php", ".exe", ".bat" ] + static: + dir: "public" + forbid: [ ".php", ".htaccess" ] + +logs: + mode: production + channels: + http: + level: debug # Log all http requests, set to info to disable + server: + level: info # Everything written to worker stderr is logged + mode: raw + metrics: + level: error + +# Uncomment to use metrics integration +# rpc: +# listen: tcp://127.0.0.1:6001 + +# Uncomment to use metrics integration +# metrics: +# # prometheus client address (path /metrics added automatically) +# address: "0.0.0.0:9180" diff --git a/composer.json b/composer.json index ab6d63e7..49d633f4 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "ext-json": "*", "ext-mongodb": "*", "ext-simplexml": "*", + "ext-sockets": "*", "ext-zip": "*", "aws/aws-sdk-php": "^3.171", "doctrine/common": "^3.1", @@ -63,7 +64,8 @@ "doctrine/mongodb-odm-bundle": "*", "fidry/cpu-core-counter": "^1.1", "knplabs/doctrine-behaviors": "*", - "symfony/notifier": "^6.4.0" + "symfony/notifier": "^6.4.0", + "baldinof/roadrunner-bundle": "^3.1" }, "require-dev": { "ext-pcntl": "*", diff --git a/composer.lock b/composer.lock index 58a6ca16..a6df5a77 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0db9e6a087ae9ac17dc8fd4e98056a2d", + "content-hash": "a1addfc5ebdba21839ffaf355bb8d869", "packages": [ { "name": "aws/aws-crt-php", @@ -155,6 +155,93 @@ }, "time": "2024-05-09T18:32:58+00:00" }, + { + "name": "baldinof/roadrunner-bundle", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/Baldinof/roadrunner-bundle.git", + "reference": "5c4b6313649da5f18632526a953fe2199bb7c3b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Baldinof/roadrunner-bundle/zipball/5c4b6313649da5f18632526a953fe2199bb7c3b9", + "reference": "5c4b6313649da5f18632526a953fe2199bb7c3b9", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "spiral/goridge": "^4.0", + "spiral/roadrunner": "^2023.1.0", + "spiral/roadrunner-http": "^3.0", + "spiral/roadrunner-worker": "^3.0.0", + "symfony/config": "^6.0 || ^7.0", + "symfony/dependency-injection": "^6.0 || ^7.0", + "symfony/http-kernel": "^6.0 || ^7.0", + "symfony/yaml": "^6.0 || ^7.0" + }, + "conflict": { + "doctrine/doctrine-bundle": "<2.1.1", + "sentry/sentry-symfony": "<4.5.0", + "spiral/roadrunner-metrics": "<3.0.0" + }, + "require-dev": { + "blackfire/php-sdk": "^1.21", + "doctrine/doctrine-bundle": "^2.1.1", + "doctrine/mongodb-odm": "^2.2", + "doctrine/orm": "^2.7.3", + "laminas/laminas-zendframework-bridge": "^1.4", + "mikey179/vfsstream": "^1.6.8", + "nyholm/psr7": "^1.2", + "sentry/sentry-symfony": "^4.5 || ^5.0", + "spiral/roadrunner-grpc": "^3.0.0", + "spiral/roadrunner-kv": "^4.0", + "spiral/roadrunner-metrics": "^3.0.0", + "symfony/framework-bundle": "^6.0 || ^7.0", + "symfony/proxy-manager-bridge": "^6.0 || ^7.0", + "symfony/runtime": "^6.0 || ^7.0", + "symfony/validator": "^6.0 || ^7.0", + "symfony/var-dumper": "^6.0 || ^7.0", + "symfony/var-exporter": "^6.0 || ^7.0" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation", + "spiral/roadrunner-cli": "For easy installation of RoadRunner", + "symfony/proxy-manager-bridge": "For doctrine re-connection implementation" + }, + "type": "symfony-bundle", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Baldinof\\RoadRunnerBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Florent Baldino", + "email": "baldinof@gmail.com" + } + ], + "description": "A RoadRunner worker as a Symfony Bundle", + "support": { + "issues": "https://github.com/Baldinof/roadrunner-bundle/issues", + "source": "https://github.com/Baldinof/roadrunner-bundle/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/Baldinof", + "type": "github" + } + ], + "time": "2024-04-29T20:37:20+00:00" + }, { "name": "brick/math", "version": "0.12.1", @@ -2282,6 +2369,50 @@ ], "time": "2024-03-20T12:50:41+00:00" }, + { + "name": "google/protobuf", + "version": "v3.25.3", + "source": { + "type": "git", + "url": "https://github.com/protocolbuffers/protobuf-php.git", + "reference": "983a87f4f8798a90ca3a25b0f300b8fda38df643" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/983a87f4f8798a90ca3a25b0f300b8fda38df643", + "reference": "983a87f4f8798a90ca3a25b0f300b8fda38df643", + "shasum": "" + }, + "require": { + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": ">=5.0.0" + }, + "suggest": { + "ext-bcmath": "Need to support JSON deserialization" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Protobuf\\": "src/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "src/GPBMetadata/Google/Protobuf" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "proto library for PHP", + "homepage": "https://developers.google.com/protocol-buffers/", + "keywords": [ + "proto" + ], + "support": { + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v3.25.3" + }, + "time": "2024-02-15T21:11:49+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.8.1", @@ -5125,6 +5256,73 @@ ], "time": "2024-04-27T21:32:50+00:00" }, + { + "name": "roadrunner-php/roadrunner-api-dto", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-php/roadrunner-api-dto.git", + "reference": "d46b24f8b51ca0bca36aa74df60822f024d8c6dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-php/roadrunner-api-dto/zipball/d46b24f8b51ca0bca36aa74df60822f024d8c6dd", + "reference": "d46b24f8b51ca0bca36aa74df60822f024d8c6dd", + "shasum": "" + }, + "require": { + "google/protobuf": "^v3.22", + "php": "^8.1" + }, + "conflict": { + "temporal/sdk": "<2.9.0" + }, + "suggest": { + "google/common-protos": "Required for Temporal API" + }, + "type": "library", + "autoload": { + "psr-4": { + "Temporal\\": "generated/Temporal", + "RoadRunner\\": "generated/RoadRunner", + "GPBMetadata\\": "generated/GPBMetadata" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Pavel Butchnev (butschster)", + "email": "pavel.buchnev@spiralscout.com" + }, + { + "name": "Aleksei Gagarin (roxblnfk)", + "email": "alexey.gagarin@spiralscout.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner PHP API", + "homepage": "https://roadrunner.dev", + "support": { + "chat": "https://discord.gg/V6EK4he", + "docs": "https://docs.roadrunner.dev", + "forum": "https://forum.roadrunner.dev", + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-php/roadrunner-api-dto/tree/v1.7.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/roadrunner-server", + "type": "github" + } + ], + "time": "2024-04-11T14:08:46+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.1", @@ -6904,6 +7102,316 @@ ], "time": "2023-11-23T20:39:43+00:00" }, + { + "name": "spiral/goridge", + "version": "v4.2.0", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-php/goridge.git", + "reference": "c6696bd1834f5e88d1252a953a1336c041795411" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-php/goridge/zipball/c6696bd1834f5e88d1252a953a1336c041795411", + "reference": "c6696bd1834f5e88d1252a953a1336c041795411", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-sockets": "*", + "php": ">=8.1", + "spiral/roadrunner": "^2023 || ^2024.1" + }, + "require-dev": { + "google/protobuf": "^3.22", + "infection/infection": "^0.26.1", + "jetbrains/phpstorm-attributes": "^1.0", + "phpunit/phpunit": "^10.0", + "rybakit/msgpack": "^0.7", + "vimeo/psalm": "^5.9" + }, + "suggest": { + "ext-msgpack": "MessagePack codec support", + "ext-protobuf": "Protobuf codec support", + "google/protobuf": "(^3.0) Protobuf codec support", + "rybakit/msgpack": "(^0.7) MessagePack codec support" + }, + "type": "goridge", + "autoload": { + "psr-4": { + "Spiral\\Goridge\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov (wolfy-j)", + "email": "wolfy-j@spiralscout.com" + }, + { + "name": "Valery Piashchynski", + "homepage": "https://github.com/rustatian" + }, + { + "name": "Aleksei Gagarin (roxblnfk)", + "homepage": "https://github.com/roxblnfk" + }, + { + "name": "Pavel Buchnev (butschster)", + "email": "pavel.buchnev@spiralscout.com" + }, + { + "name": "Maksim Smakouz (msmakouz)", + "email": "maksim.smakouz@spiralscout.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "High-performance PHP-to-Golang RPC bridge", + "homepage": "https://spiral.dev/", + "support": { + "chat": "https://discord.gg/V6EK4he", + "docs": "https://docs.roadrunner.dev", + "forum": "https://forum.roadrunner.dev/", + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-php/goridge/tree/v4.2.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/roadrunner-server", + "type": "github" + } + ], + "time": "2024-04-11T17:26:14+00:00" + }, + { + "name": "spiral/roadrunner", + "version": "v2023.3.12", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-server/roadrunner.git", + "reference": "9b5b65e00c6de7327142a8d689646f950fe00788" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-server/roadrunner/zipball/9b5b65e00c6de7327142a8d689646f950fe00788", + "reference": "9b5b65e00c6de7327142a8d689646f950fe00788", + "shasum": "" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov / Wolfy-J", + "email": "wolfy.jd@gmail.com" + }, + { + "name": "Valery Piashchynski", + "homepage": "https://github.com/rustatian" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins", + "homepage": "https://roadrunner.dev/", + "support": { + "chat": "https://discord.gg/V6EK4he", + "docs": "https://roadrunner.dev/docs", + "forum": "https://forum.roadrunner.dev/", + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-server/roadrunner/tree/v2023.3.12" + }, + "funding": [ + { + "url": "https://github.com/sponsors/roadrunner-server", + "type": "github" + } + ], + "time": "2024-02-29T18:16:45+00:00" + }, + { + "name": "spiral/roadrunner-http", + "version": "v3.5.1", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-php/http.git", + "reference": "213cd0d5c0fba1548f22a5f5ff333afa88fe24ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-php/http/zipball/213cd0d5c0fba1548f22a5f5ff333afa88fe24ae", + "reference": "213cd0d5c0fba1548f22a5f5ff333afa88fe24ae", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=8.1", + "psr/http-factory": "^1.0.1", + "psr/http-message": "^1.0.1 || ^2.0", + "roadrunner-php/roadrunner-api-dto": "^1.6", + "spiral/roadrunner": "^2023.3 || ^2024.1", + "spiral/roadrunner-worker": "^3.5", + "symfony/polyfill-php83": "^1.29" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "nyholm/psr7": "^1.3", + "phpunit/phpunit": "^10.0", + "symfony/process": "^6.2 || ^7.0", + "vimeo/psalm": "^5.9" + }, + "suggest": { + "ext-protobuf": "Provides Protocol Buffers support. Without it, performance will be lower.", + "spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spiral\\RoadRunner\\Http\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov (wolfy-j)", + "email": "wolfy-j@spiralscout.com" + }, + { + "name": "Valery Piashchynski", + "homepage": "https://github.com/rustatian" + }, + { + "name": "Aleksei Gagarin (roxblnfk)", + "homepage": "https://github.com/roxblnfk" + }, + { + "name": "Pavel Buchnev (butschster)", + "email": "pavel.buchnev@spiralscout.com" + }, + { + "name": "Maksim Smakouz (msmakouz)", + "email": "maksim.smakouz@spiralscout.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: HTTP and PSR-7 worker", + "homepage": "https://spiral.dev/", + "support": { + "chat": "https://discord.gg/V6EK4he", + "docs": "https://docs.roadrunner.dev", + "forum": "https://forum.roadrunner.dev/", + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-php/http/tree/v3.5.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/roadrunner-server", + "type": "github" + } + ], + "time": "2024-04-26T11:16:10+00:00" + }, + { + "name": "spiral/roadrunner-worker", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-php/worker.git", + "reference": "7c7411a301b9dade863634ab17ef01929adada6b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-php/worker/zipball/7c7411a301b9dade863634ab17ef01929adada6b", + "reference": "7c7411a301b9dade863634ab17ef01929adada6b", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0", + "ext-json": "*", + "ext-sockets": "*", + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0", + "spiral/goridge": "^4.1.0", + "spiral/roadrunner": "^2023.1 || ^2024.1" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "phpunit/phpunit": "^10.0", + "symfony/var-dumper": "^6.3 || ^7.0", + "vimeo/psalm": "^5.9" + }, + "suggest": { + "spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spiral\\RoadRunner\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov (wolfy-j)", + "email": "wolfy-j@spiralscout.com" + }, + { + "name": "Valery Piashchynski", + "homepage": "https://github.com/rustatian" + }, + { + "name": "Aleksei Gagarin (roxblnfk)", + "homepage": "https://github.com/roxblnfk" + }, + { + "name": "Pavel Buchnev (butschster)", + "email": "pavel.buchnev@spiralscout.com" + }, + { + "name": "Maksim Smakouz (msmakouz)", + "email": "maksim.smakouz@spiralscout.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: PHP worker", + "homepage": "https://spiral.dev/", + "support": { + "chat": "https://discord.gg/V6EK4he", + "docs": "https://docs.roadrunner.dev", + "forum": "https://forum.roadrunner.dev/", + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-php/worker/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/roadrunner-server", + "type": "github" + } + ], + "time": "2024-03-29T08:06:36+00:00" + }, { "name": "symfony/amqp-messenger", "version": "v6.4.7", @@ -14786,6 +15294,7 @@ "ext-json": "*", "ext-mongodb": "*", "ext-simplexml": "*", + "ext-sockets": "*", "ext-zip": "*" }, "platform-dev": { diff --git a/config/bundles.php b/config/bundles.php index a4b46ba5..74151c15 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -30,4 +30,5 @@ Draw\Bundle\SonataImportBundle\DrawSonataImportBundle::class => ['all' => true], Knp\DoctrineBehaviors\DoctrineBehaviorsBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Baldinof\RoadRunnerBundle\BaldinofRoadRunnerBundle::class => ['all' => true], ]; diff --git a/config/packages/baldinof_road_runner.yaml b/config/packages/baldinof_road_runner.yaml new file mode 100644 index 00000000..613ec38f --- /dev/null +++ b/config/packages/baldinof_road_runner.yaml @@ -0,0 +1,27 @@ +baldinof_road_runner: + # When the kernel should be rebooted. + # See https://github.com/baldinof/roadrunner-bundle#kernel-reboots + kernel_reboot: + # if you want to use a fresh container on each request, use the `always` strategy + strategy: on_exception + # Exceptions you KNOW that do not put your app in an unrecoverable state + allowed_exceptions: + - Symfony\Component\HttpKernel\Exception\HttpExceptionInterface + - Symfony\Component\Serializer\Exception\ExceptionInterface + - Symfony\Contracts\HttpClient\Exception\ExceptionInterface + + # Allow to send prometheus metrics to the main RoadRunner process, + # via a `Spiral\RoadRunner\MetricsInterface` service. + # See https://github.com/baldinof/roadrunner-bundle#metrics + metrics: + enabled: false + # collect: + # my_counter: + # type: counter + # help: Some help + + + # You can use middlewares to manipulate Symfony requests & responses. + # See https://github.com/baldinof/roadrunner-bundle#middlewares + # middlewares: + # - App\Middleware\YourMiddleware diff --git a/symfony.lock b/symfony.lock index 576a29d2..9eb916bf 100644 --- a/symfony.lock +++ b/symfony.lock @@ -20,6 +20,18 @@ "bacon/bacon-qr-code": { "version": "2.0.4" }, + "baldinof/roadrunner-bundle": { + "version": "3.1", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "3.0", + "ref": "0da69c96650460102ed0a2a0004e5b347f7220c9" + }, + "files": [ + "config/packages/baldinof_road_runner.yaml" + ] + }, "bamarni/composer-bin-plugin": { "version": "v1.5.0" },