diff --git a/.gitignore b/.gitignore index 8e6e288..2c6339e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ ###> symfony/web-server-bundle ### /.web-server-pid ###< symfony/web-server-bundle ### + +###> baldinof/roadrunner-bundle ### +/bin/rr +###< baldinof/roadrunner-bundle ### diff --git a/.rr.dev.yaml b/.rr.dev.yaml new file mode 100644 index 0000000..9555ab5 --- /dev/null +++ b/.rr.dev.yaml @@ -0,0 +1,38 @@ +version: "2.7" + +server: + command: "php public/index.php" + # If you are not using symfony 5.3+ and the new Runtime component: + # remove the previous `command` line above and uncomment the line below to use the deprecated command. + # command: "php bin/console baldinof:roadrunner:worker" + env: + - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime + +http: + address: 0.0.0.0:8080 + 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 + +reload: + enabled: true + interval: 1s + patterns: [".php", ".yaml"] + services: + http: + dirs: ["."] + recursive: true diff --git a/.rr.yaml b/.rr.yaml new file mode 100644 index 0000000..0f0a352 --- /dev/null +++ b/.rr.yaml @@ -0,0 +1,38 @@ +version: "2.7" + +server: + command: "php public/index.php" + # If you are not using symfony 5.3+ and the new Runtime component: + # remove the previous `command` line above and uncomment the line below to use the deprecated command. + # command: "php bin/console baldinof:roadrunner:worker" + env: + - APP_RUNTIME: Baldinof\RoadRunnerBundle\Runtime\Runtime + +http: + address: 0.0.0.0:8080 + 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/bin/console b/bin/console index 19c2f6c..47e5d5b 100755 --- a/bin/console +++ b/bin/console @@ -1,42 +1,18 @@ #!/usr/bin/env php getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -require dirname(__DIR__).'/config/bootstrap.php'; - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists(Debug::class)) { - Debug::enable(); - } -} - -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Application($kernel); -$application->run($input); + return new Application($kernel); +}; diff --git a/composer.json b/composer.json index cc19ec4..1d6c558 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "ext-iconv": "*", "ext-json": "*", "babdev/pagerfanta-bundle": "^3.0", + "baldinof/roadrunner-bundle": "^2.2", "composer/package-versions-deprecated": "1.11.99.5", "doctrine/annotations": "^1.0", "doctrine/doctrine-bundle": "^2", diff --git a/composer.lock b/composer.lock index c789f25..503111c 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": "04ea4d4680609411d25859ab8e58b6d3", + "content-hash": "a73ab7580901f6ec9553791cc6b3a72c", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -89,6 +89,94 @@ ], "time": "2022-05-27T20:58:26+00:00" }, + { + "name": "baldinof/roadrunner-bundle", + "version": "2.2.3", + "source": { + "type": "git", + "url": "https://github.com/Baldinof/roadrunner-bundle.git", + "reference": "948e8e6d01b1df68aea0ef9bba60aca593d0eae5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Baldinof/roadrunner-bundle/zipball/948e8e6d01b1df68aea0ef9bba60aca593d0eae5", + "reference": "948e8e6d01b1df68aea0ef9bba60aca593d0eae5", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "spiral/goridge": "^3.0", + "spiral/roadrunner": "^2.0.2", + "spiral/roadrunner-worker": "^2.1.4", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", + "symfony/psr-http-message-bridge": "^1.1 || ^2.0", + "symfony/yaml": "^4.4 || ^5.0 || ^6.0" + }, + "conflict": { + "doctrine/doctrine-bundle": "<2.1.1", + "sentry/sentry-symfony": "<4.0.0", + "spiral/roadrunner-metrics": "<2.0.1" + }, + "require-dev": { + "blackfire/php-sdk": "^1.21", + "doctrine/doctrine-bundle": "^2.1.1", + "doctrine/mongodb-odm": "^2.2", + "doctrine/orm": "^2.7.3", + "friendsofphp/php-cs-fixer": "^3.4", + "laminas/laminas-zendframework-bridge": "^1.4", + "mikey179/vfsstream": "^1.6.8", + "nyholm/psr7": "^1.2", + "phpspec/prophecy": "^1.11", + "phpspec/prophecy-phpunit": "^2.0", + "phpstan/phpstan": "^1.2", + "phpunit/phpunit": "^9.5", + "sentry/sentry-symfony": "^4.0", + "spiral/roadrunner-grpc": "^2.0", + "spiral/roadrunner-metrics": "^2.0.1", + "symfony/framework-bundle": "^4.0 || ^5.0 || ^6.0", + "symfony/proxy-manager-bridge": "^4.0 || ^5.0 || ^6.0", + "symfony/runtime": "^5.3.0 || ^6.0", + "symfony/var-dumper": "^4.0 || ^5.0 || ^6.0" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation", + "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/2.2.3" + }, + "funding": [ + { + "url": "https://github.com/Baldinof", + "type": "github" + } + ], + "time": "2022-05-29T21:53:52+00:00" + }, { "name": "clue/stream-filter", "version": "v1.6.0", @@ -228,6 +316,87 @@ ], "time": "2022-01-17T14:14:24+00:00" }, + { + "name": "composer/semver", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-04-01T19:23:25+00:00" + }, { "name": "doctrine/annotations", "version": "1.13.3", @@ -3820,6 +3989,299 @@ ], "time": "2022-05-30T12:09:35+00:00" }, + { + "name": "spiral/goridge", + "version": "v3.2.0", + "source": { + "type": "git", + "url": "https://github.com/spiral/goridge-php.git", + "reference": "3d8e97d7d1cc26b6130d233177b23ecb3c7d4efb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spiral/goridge-php/zipball/3d8e97d7d1cc26b6130d233177b23ecb3c7d4efb", + "reference": "3d8e97d7d1cc26b6130d233177b23ecb3c7d4efb", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-sockets": "*", + "php": ">=7.4", + "symfony/polyfill-php80": "^1.22" + }, + "require-dev": { + "google/protobuf": "^3.17", + "infection/infection": "^0.26.1", + "jetbrains/phpstorm-attributes": "^1.0", + "phpunit/phpunit": "^9.5", + "rybakit/msgpack": "^0.7", + "vimeo/psalm": "^4.18.1" + }, + "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", + "extra": { + "branch-alias": { + "dev-master": "3.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Spiral\\Goridge\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov / Wolfy-J", + "email": "wolfy.jd@gmail.com" + } + ], + "description": "High-performance PHP-to-Golang RPC bridge", + "support": { + "issues": "https://github.com/spiral/goridge-php/issues", + "source": "https://github.com/spiral/goridge-php/tree/v3.2.0" + }, + "time": "2022-03-21T20:32:19+00:00" + }, + { + "name": "spiral/roadrunner", + "version": "v2.10.5", + "source": { + "type": "git", + "url": "https://github.com/roadrunner-server/roadrunner.git", + "reference": "3996ba6d12f953f808408e276f69dfcf0950e906" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roadrunner-server/roadrunner/zipball/3996ba6d12f953f808408e276f69dfcf0950e906", + "reference": "3996ba6d12f953f808408e276f69dfcf0950e906", + "shasum": "" + }, + "require": { + "spiral/roadrunner-cli": "^2.0", + "spiral/roadrunner-http": "^2.0", + "spiral/roadrunner-worker": "^2.0" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov / Wolfy-J", + "email": "wolfy.jd@gmail.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/roadrunner-server/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: High-performance PHP application server, load-balancer and process manager written in Golang", + "support": { + "issues": "https://github.com/roadrunner-server/roadrunner/issues", + "source": "https://github.com/roadrunner-server/roadrunner/tree/v2.10.5" + }, + "time": "2022-06-23T20:54:36+00:00" + }, + { + "name": "spiral/roadrunner-cli", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/spiral/roadrunner-cli.git", + "reference": "d8a224137b1d1ace0aac2308df396403393d63a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spiral/roadrunner-cli/zipball/d8a224137b1d1ace0aac2308df396403393d63a8", + "reference": "d8a224137b1d1ace0aac2308df396403393d63a8", + "shasum": "" + }, + "require": { + "composer/semver": "^3.2", + "ext-json": "*", + "php": ">=7.4", + "spiral/roadrunner-worker": ">=2.0.2", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/polyfill-php80": "^1.22" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "symfony/var-dumper": "^4.4|^5.0", + "vimeo/psalm": "^4.4" + }, + "bin": [ + "bin/rr" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Spiral\\RoadRunner\\Console\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov (wolfy-j)", + "email": "wolfy-j@spiralscout.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/spiral/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: Command Line Interface", + "support": { + "issues": "https://github.com/spiral/roadrunner-cli/issues", + "source": "https://github.com/spiral/roadrunner-cli/tree/v2.2.0" + }, + "time": "2022-05-17T06:44:24+00:00" + }, + { + "name": "spiral/roadrunner-http", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/spiral/roadrunner-http.git", + "reference": "3be8bac365d436028a9583e7d438bf6e7183e599" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spiral/roadrunner-http/zipball/3be8bac365d436028a9583e7d438bf6e7183e599", + "reference": "3be8bac365d436028a9583e7d438bf6e7183e599", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.4", + "psr/http-factory": "^1.0.1", + "psr/http-message": "^1.0.1", + "spiral/roadrunner-worker": "^2.2.0" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "nyholm/psr7": "^1.3", + "phpstan/phpstan": "~0.12", + "phpunit/phpunit": "~8.0", + "symfony/var-dumper": "^5.1", + "vimeo/psalm": "^4.22" + }, + "suggest": { + "spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Spiral\\RoadRunner\\Http\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Titov / Wolfy-J", + "email": "wolfy.jd@gmail.com" + }, + { + "name": "RoadRunner Community", + "homepage": "https://github.com/spiral/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: HTTP and PSR-7 worker", + "support": { + "issues": "https://github.com/spiral/roadrunner-http/issues", + "source": "https://github.com/spiral/roadrunner-http/tree/v2.1.0" + }, + "time": "2022-03-22T14:48:00+00:00" + }, + { + "name": "spiral/roadrunner-worker", + "version": "v2.2.0", + "source": { + "type": "git", + "url": "https://github.com/spiral/roadrunner-worker.git", + "reference": "97399e1f45b188e4288817672df858908b641401" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spiral/roadrunner-worker/zipball/97399e1f45b188e4288817672df858908b641401", + "reference": "97399e1f45b188e4288817672df858908b641401", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2.0", + "ext-json": "*", + "ext-sockets": "*", + "php": ">=7.4", + "psr/log": "^1.0|^2.0|^3.0", + "spiral/goridge": "^3.2.0", + "symfony/polyfill-php80": "^1.23" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "symfony/var-dumper": "^5.1", + "vimeo/psalm": "^4.4" + }, + "suggest": { + "spiral/roadrunner-cli": "Provides RoadRunner installation and management CLI tools" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "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": "RoadRunner Community", + "homepage": "https://github.com/spiral/roadrunner/graphs/contributors" + } + ], + "description": "RoadRunner: PHP worker", + "support": { + "issues": "https://github.com/spiral/roadrunner-worker/issues", + "source": "https://github.com/spiral/roadrunner-worker/tree/v2.2.0" + }, + "time": "2022-03-22T11:03:47+00:00" + }, { "name": "suin/php-rss-writer", "version": "1.6.0", diff --git a/config/bundles.php b/config/bundles.php index 3ebc981..2e59001 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -13,4 +13,5 @@ return [ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Sentry\SentryBundle\SentryBundle::class => ['all' => true], EWZ\Bundle\RecaptchaBundle\EWZRecaptchaBundle::class => ['all' => 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 0000000..3728e09 --- /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 errored 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 797b57d..362d077 100644 --- a/symfony.lock +++ b/symfony.lock @@ -2,6 +2,18 @@ "babdev/pagerfanta-bundle": { "version": "v2.4.3" }, + "baldinof/roadrunner-bundle": { + "version": "2.2", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "2.0", + "ref": "cdd398712fbc03897c0550c856df05fb9ab2b36b" + }, + "files": [ + "config/packages/baldinof_road_runner.yaml" + ] + }, "clue/stream-filter": { "version": "v1.4.1" },