From 96ed7cae0d994ad2f5490946895eeb8a845f82a5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 16 Feb 2024 23:02:46 +0100 Subject: [PATCH] Drop support for openswoole --- .github/DISCUSSION_TEMPLATE/help-wanted.yml | 4 +- .github/ISSUE_TEMPLATE/Bug.yml | 4 +- .github/workflows/ci-db-tests.yml | 2 +- .github/workflows/ci-mutation-tests.yml | 1 - .github/workflows/ci-tests.yml | 1 - .github/workflows/ci.yml | 23 +---- .github/workflows/publish-release.yml | 9 +- .github/workflows/publish-swagger-spec.yml | 1 - CHANGELOG.md | 2 +- CONTRIBUTING.md | 6 +- Dockerfile | 2 +- README.md | 5 +- bin/test/run-api-tests.sh | 5 +- composer.json | 9 +- config/autoload/common.global.php | 2 +- config/autoload/logger.global.php | 11 --- config/autoload/router.global.php | 2 +- config/autoload/swoole.global.php | 34 -------- config/autoload/swoole.local.php.dist | 13 --- config/autoload/url-shortener.local.php.dist | 2 - config/config.php | 10 --- config/container.php | 11 --- config/test/test_config.global.php | 15 ---- .../examples/shlink-daemon-logrotate.conf | 13 --- data/infra/examples/shlink-daemon.sh | 54 ------------ data/infra/swoole.Dockerfile | 85 ------------------- data/infra/swoole_proxy_vhost.conf | 14 --- docker-compose.override.yml.dist | 6 -- docker-compose.yml | 38 --------- docker/README.md | 2 +- indocker | 4 +- .../Core/config/event_dispatcher.config.php | 3 +- module/Core/src/ShortUrl/UrlShortener.php | 2 +- 33 files changed, 26 insertions(+), 369 deletions(-) delete mode 100644 config/autoload/swoole.global.php delete mode 100644 config/autoload/swoole.local.php.dist delete mode 100644 data/infra/examples/shlink-daemon-logrotate.conf delete mode 100644 data/infra/examples/shlink-daemon.sh delete mode 100644 data/infra/swoole.Dockerfile delete mode 100644 data/infra/swoole_proxy_vhost.conf diff --git a/.github/DISCUSSION_TEMPLATE/help-wanted.yml b/.github/DISCUSSION_TEMPLATE/help-wanted.yml index 1283f43d..08444522 100644 --- a/.github/DISCUSSION_TEMPLATE/help-wanted.yml +++ b/.github/DISCUSSION_TEMPLATE/help-wanted.yml @@ -20,10 +20,8 @@ body: options: - Self-hosted Apache - Self-hosted nginx - - Self-hosted openswoole - Self-hosted RoadRunner - - Openswoole Docker image - - RoadRunner Docker image + - Docker image - Other (explain in summary) - type: dropdown validations: diff --git a/.github/ISSUE_TEMPLATE/Bug.yml b/.github/ISSUE_TEMPLATE/Bug.yml index 1f715088..2fce5cf4 100644 --- a/.github/ISSUE_TEMPLATE/Bug.yml +++ b/.github/ISSUE_TEMPLATE/Bug.yml @@ -22,10 +22,8 @@ body: options: - Self-hosted Apache - Self-hosted nginx - - Self-hosted openswoole - Self-hosted RoadRunner - - Openswoole Docker image - - RoadRunner Docker image + - Docker image - Other (explain in summary) - type: dropdown validations: diff --git a/.github/workflows/ci-db-tests.yml b/.github/workflows/ci-db-tests.yml index f2aaefb9..dd797e83 100644 --- a/.github/workflows/ci-db-tests.yml +++ b/.github/workflows/ci-db-tests.yml @@ -27,7 +27,7 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2, pdo_sqlsrv-5.12.0 + php-extensions: pdo_sqlsrv-5.12.0 extensions-cache-key: db-tests-extensions-${{ matrix.php-version }}-${{ inputs.platform }} - name: Create test database if: ${{ inputs.platform == 'ms' }} diff --git a/.github/workflows/ci-mutation-tests.yml b/.github/workflows/ci-mutation-tests.yml index 64da4adc..c34902d3 100644 --- a/.github/workflows/ci-mutation-tests.yml +++ b/.github/workflows/ci-mutation-tests.yml @@ -19,7 +19,6 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2 extensions-cache-key: mutation-tests-extensions-${{ matrix.php-version }}-${{ inputs.test-group }} - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 440ca0b2..ea26ccd7 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -27,7 +27,6 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2 extensions-cache-key: tests-extensions-${{ matrix.php-version }}-${{ inputs.test-group }} - name: Download RoadRunner binary if: ${{ inputs.test-group == 'api' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 016daf0a..c3289dc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,6 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2 extensions-cache-key: tests-extensions-${{ matrix.php-version }}-${{ matrix.command }} - run: composer ${{ matrix.command }} @@ -50,27 +49,11 @@ jobs: with: test-group: cli - roadrunner-api-tests: + api-tests: uses: './.github/workflows/ci-tests.yml' with: test-group: api - openswoole-api-tests: - runs-on: ubuntu-22.04 - strategy: - matrix: - php-version: ['8.2', '8.3'] - steps: - - uses: actions/checkout@v4 - - run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_postgres - - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: openswoole-22.1.2 - tools: composer - - run: composer install --no-interaction --prefer-dist - - run: composer test:api:openswoole - sqlite-db-tests: uses: './.github/workflows/ci-db-tests.yml' with: @@ -112,7 +95,7 @@ jobs: api-mutation-tests: needs: - - openswoole-api-tests + - api-tests uses: './.github/workflows/ci-mutation-tests.yml' with: test-group: api @@ -127,7 +110,7 @@ jobs: upload-coverage: needs: - unit-tests - - openswoole-api-tests + - api-tests - cli-tests - sqlite-db-tests runs-on: ubuntu-22.04 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 76d04f94..7875c07b 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -11,22 +11,17 @@ jobs: strategy: matrix: php-version: ['8.2', '8.3'] - swoole: ['yes', 'no'] steps: - uses: actions/checkout@v4 - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2 extensions-cache-key: publish-swagger-spec-extensions-${{ matrix.php-version }} install-deps: 'no' - - if: ${{ matrix.swoole == 'yes' }} - run: ./build.sh ${GITHUB_REF#refs/tags/v} - - if: ${{ matrix.swoole == 'no' }} - run: ./build.sh ${GITHUB_REF#refs/tags/v} --no-swoole + - run: ./build.sh ${GITHUB_REF#refs/tags/v} - uses: actions/upload-artifact@v4 with: - name: dist-files-${{ matrix.php-version }}-${{ matrix.swoole }} + name: dist-files-${{ matrix.php-version }} path: build publish: diff --git a/.github/workflows/publish-swagger-spec.yml b/.github/workflows/publish-swagger-spec.yml index aa7e5e93..beebf57f 100644 --- a/.github/workflows/publish-swagger-spec.yml +++ b/.github/workflows/publish-swagger-spec.yml @@ -20,7 +20,6 @@ jobs: - uses: './.github/actions/ci-setup' with: php-version: ${{ matrix.php-version }} - php-extensions: openswoole-22.1.2 extensions-cache-key: publish-swagger-spec-extensions-${{ matrix.php-version }} - run: composer swagger:inline - run: mkdir ${{ steps.determine_version.outputs.version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index cf38bf96..92036903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * *Nothing* ### Removed -* *Nothing* +* [#1908](https://github.com/shlinkio/shlink/issues/1908) Remove support for openswoole (and swoole). ### Fixed * *Nothing* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b2f36d2..e9a77964 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Then you will have to follow these steps: * Run `./indocker bin/cli db:migrate` to get database migrations up to date. * Run `./indocker bin/cli api-key:generate` to get your first API key generated. -Once you finish this, you will have the project exposed in ports `8800` through RoadRunner, `8080` through openswoole and `8000` through nginx+php-fpm. +Once you finish this, you will have the project exposed in ports `8800` through RoadRunner and `8000` through nginx+php-fpm. > Note: The `indocker` shell script is a helper tool used to run commands inside the main docker container. @@ -80,7 +80,7 @@ The purposes of every folder are: * `data`: Common git-ignored assets, like logs, caches, lock files, GeoLite DB files, etc. It's the only location where Shlink may need to write at runtime. * `docs`: Any project documentation is stored here, like API spec definitions or architectural decision records. * `module`: Contains a sub-folder for every module in the project. Modules contain the source code, tests and configurations for every context in the project. -* `public`: Few assets (like `favicon.ico` or `robots.txt`) and the web entry point are stored here. This web entry point is not used when serving the app with RoadRunner or openswoole. +* `public`: Few assets (like `favicon.ico` or `robots.txt`) and the web entry point are stored here. This web entry point is not used when serving the app with RoadRunner. ## Project tests @@ -96,7 +96,7 @@ In order to ensure stability and no regressions are introduced while developing The project provides some tooling to run them against any of the supported database engines. -* **API tests**: These are E2E tests that spin up an instance of the app with RoadRunner or openswoole, and test it from the outside by interacting with the REST API. +* **API tests**: These are E2E tests that spin up an instance of the app with RoadRunner, and test it from the outside by interacting with the REST API. These are the best tests to catch regressions, and to verify everything behaves as expected. diff --git a/Dockerfile b/Dockerfile index 4ad94dc9..4251b3e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ FROM base as builder COPY . . COPY --from=composer:2 /usr/bin/composer ./composer.phar RUN apk add --no-cache git && \ - php composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction --ignore-platform-req=ext-openswoole && \ + php composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-interaction && \ php composer.phar clear-cache && \ rm -r docker composer.* && \ sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php diff --git a/README.md b/README.md index 7e84d5ae..2a2d3f6c 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,11 @@ First, make sure the host where you are going to run shlink fulfills these requi * PHP 8.2 or 8.3 * The next PHP extensions: json, curl, pdo, intl, gd and gmp/bcmath. - * apcu extension is recommended if you don't plan to use openswoole. + * apcu extension is recommended if you don't plan to use RoadRunner. * xml extension is required if you want to generate QR codes in svg format. * sockets and bcmath extensions are required if you want to integrate with a RabbitMQ instance. * MySQL, MariaDB, PostgreSQL, MicrosoftSQL or SQLite. * You will also need the corresponding pdo variation for the database you are planning to use: `pdo_mysql`, `pdo_pgsql`, `pdo_sqlsrv` or `pdo_sqlite`. -* The [openswoole](https://openswoole.com/) PHP extension (if you plan to serve Shlink with openswoole) or the web server of your choice with PHP integration (like Apache or Nginx). ### Download @@ -53,7 +52,7 @@ In order to run Shlink, you will need a built version of the project. There are The easiest way to install shlink is by using one of the pre-bundled distributable packages. - Go to the [latest version](https://github.com/shlinkio/shlink/releases/latest) and download the `shlink*_dist.zip` file that suits your needs. You will find one for every supported PHP version and with/without openswoole integration. + Go to the [latest version](https://github.com/shlinkio/shlink/releases/latest) and download the `shlink*_dist.zip` file that suits your needs. You will find one for every supported PHP version. Finally, decompress the file in the location of your choice. diff --git a/bin/test/run-api-tests.sh b/bin/test/run-api-tests.sh index b4e38467..18ad2dd5 100755 --- a/bin/test/run-api-tests.sh +++ b/bin/test/run-api-tests.sh @@ -2,7 +2,7 @@ export APP_ENV=test export TEST_ENV=api -export TEST_RUNTIME="${TEST_RUNTIME:-"rr"}" # Openswoole is deprecated. Remove in v4.0.0 +export TEST_RUNTIME="${TEST_RUNTIME:-"rr"}" # rr is the only runtime currently supported export DB_DRIVER="${DB_DRIVER:-"postgres"}" export GENERATE_COVERAGE="${GENERATE_COVERAGE:-"no"}" @@ -13,11 +13,9 @@ mkdir data/log/api-tests touch $OUTPUT_LOGS # Try to stop server just in case it hanged in last execution -[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:stop [ "$TEST_RUNTIME" = 'rr' ] && bin/rr stop -f echo 'Starting server...' -[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:start -d [ "$TEST_RUNTIME" = 'rr' ] && bin/rr serve -p -c=config/roadrunner/.rr.test.yml -w . \ -o=logs.output="${PWD}/${OUTPUT_LOGS}" \ -o=logs.channels.http.output="${PWD}/${OUTPUT_LOGS}" \ @@ -27,7 +25,6 @@ sleep 2 # Let's give the server a couple of seconds to start vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always --log-junit=build/coverage-api/junit.xml $* TESTS_EXIT_CODE=$? -[ "$TEST_RUNTIME" = 'openswoole' ] && vendor/bin/laminas mezzio:swoole:stop [ "$TEST_RUNTIME" = 'rr' ] && bin/rr stop -c config/roadrunner/.rr.dev.yml -o=http.address=0.0.0.0:9999 # Exit this script with the same code as the tests. If tests failed, this script has to fail diff --git a/composer.json b/composer.json index dabd4d0c..20da872a 100644 --- a/composer.json +++ b/composer.json @@ -37,17 +37,16 @@ "mezzio/mezzio": "^3.17", "mezzio/mezzio-fastroute": "^3.11", "mezzio/mezzio-problem-details": "^1.13", - "mezzio/mezzio-swoole": "^4.8", "mlocati/ip-lib": "^1.18", "mobiledetect/mobiledetectlib": "^4.8", "pagerfanta/core": "^3.8", "pugx/shortid-php": "^1.1", "ramsey/uuid": "^4.7", - "shlinkio/shlink-common": "dev-main#3f6b243 as 6.0", - "shlinkio/shlink-config": "^2.5", + "shlinkio/shlink-common": "dev-main#2323ff3 as 6.0", + "shlinkio/shlink-config": "dev-main#6b287b3 as 2.6", "shlinkio/shlink-event-dispatcher": "^3.1", "shlinkio/shlink-importer": "^5.2.1", - "shlinkio/shlink-installer": "dev-develop#9f0d7e5 as 9.0", + "shlinkio/shlink-installer": "dev-develop#2dee7db as 9.0", "shlinkio/shlink-ip-geolocation": "^3.4", "shlinkio/shlink-json": "^1.1", "spiral/roadrunner": "^2023.3", @@ -64,7 +63,6 @@ "devizzent/cebe-php-openapi": "^1.0.1", "devster/ubench": "^2.1", "infection/infection": "^0.27", - "openswoole/ide-helper": "~22.0.0", "phpstan/phpstan": "^1.10", "phpstan/phpstan-doctrine": "^1.3", "phpstan/phpstan-phpunit": "^1.3", @@ -130,7 +128,6 @@ "test:db:postgres": "DB_DRIVER=postgres composer test:db:sqlite", "test:db:ms": "DB_DRIVER=mssql composer test:db:sqlite", "test:api": "bin/test/run-api-tests.sh", - "test:api:openswoole": "TEST_RUNTIME=openswoole bin/test/run-api-tests.sh", "test:api:ci": "GENERATE_COVERAGE=yes composer test:api", "test:api:pretty": "GENERATE_COVERAGE=pretty composer test:api", "test:cli": "APP_ENV=test DB_DRIVER=maria TEST_ENV=cli php vendor/bin/phpunit --order-by=random --colors=always --testdox -c phpunit-cli.xml --log-junit=build/coverage-cli/junit.xml", diff --git a/config/autoload/common.global.php b/config/autoload/common.global.php index 19404d8c..c7db57f1 100644 --- a/config/autoload/common.global.php +++ b/config/autoload/common.global.php @@ -8,7 +8,7 @@ return [ 'debug' => false, - // Disabling config cache for cli, ensures it's never used for openswoole/RoadRunner, and also that console + // Disabling config cache for cli, ensures it's never used for RoadRunner, and also that console // commands don't generate a cache file that's then used by php-fpm web executions ConfigAggregator::ENABLE_CACHE => PHP_SAPI !== 'cli', diff --git a/config/autoload/logger.global.php b/config/autoload/logger.global.php index 9e5e3160..67b737ae 100644 --- a/config/autoload/logger.global.php +++ b/config/autoload/logger.global.php @@ -53,16 +53,5 @@ return (static function (): array { ], ], - // Deprecated. Remove in Shlink 4.0.0 - 'mezzio-swoole' => [ - 'swoole-http-server' => [ - 'logger' => [ - // Let's disable mezio-swoole access logging, so that we can provide our own implementation, - // consistent for roadrunner and openswoole - 'logger-name' => NullLogger::class, - ], - ], - ], - ]; })(); diff --git a/config/autoload/router.global.php b/config/autoload/router.global.php index 831a7523..d13bf7d4 100644 --- a/config/autoload/router.global.php +++ b/config/autoload/router.global.php @@ -11,7 +11,7 @@ return [ 'base_path' => EnvVars::BASE_PATH->loadFromEnv(''), 'fastroute' => [ - // Disabling config cache for cli, ensures it's never used for openswoole/RoadRunner, and also that console + // Disabling config cache for cli, ensures it's never used for RoadRunner, and also that console // commands don't generate a cache file that's then used by php-fpm web executions FastRouteRouter::CONFIG_CACHE_ENABLED => PHP_SAPI !== 'cli', FastRouteRouter::CONFIG_CACHE_FILE => 'data/cache/fastroute_cached_routes.php', diff --git a/config/autoload/swoole.global.php b/config/autoload/swoole.global.php deleted file mode 100644 index 494e3cf2..00000000 --- a/config/autoload/swoole.global.php +++ /dev/null @@ -1,34 +0,0 @@ -loadFromEnv(16); - - return [ - - 'mezzio-swoole' => [ - // Setting this to true can have unexpected behaviors when running several concurrent slow DB queries - 'enable_coroutine' => false, - - 'swoole-http-server' => [ - 'host' => '0.0.0.0', - 'port' => (int) EnvVars::PORT->loadFromEnv(8080), - 'process-name' => 'shlink', - - 'options' => [ - ...getOpenswooleConfigFromEnv(), - 'worker_num' => (int) EnvVars::WEB_WORKER_NUM->loadFromEnv(16), - 'task_worker_num' => max($taskWorkers, MIN_TASK_WORKERS), - ], - ], - ], - - ]; -})(); diff --git a/config/autoload/swoole.local.php.dist b/config/autoload/swoole.local.php.dist deleted file mode 100644 index f30b3610..00000000 --- a/config/autoload/swoole.local.php.dist +++ /dev/null @@ -1,13 +0,0 @@ - [ - 'hot-code-reload' => [ - 'enable' => true, - ], - ], - -]; diff --git a/config/autoload/url-shortener.local.php.dist b/config/autoload/url-shortener.local.php.dist index 2d129625..0b2e9db1 100644 --- a/config/autoload/url-shortener.local.php.dist +++ b/config/autoload/url-shortener.local.php.dist @@ -2,7 +2,6 @@ declare(strict_types=1); -use function Shlinkio\Shlink\Config\runningInOpenswoole; use function Shlinkio\Shlink\Config\runningInRoadRunner; return [ @@ -12,7 +11,6 @@ return [ 'schema' => 'http', 'hostname' => sprintf('localhost:%s', match (true) { runningInRoadRunner() => '8800', - runningInOpenswoole() => '8080', default => '8000', }), ], diff --git a/config/config.php b/config/config.php index a52ade5a..78fc542a 100644 --- a/config/config.php +++ b/config/config.php @@ -8,19 +8,12 @@ use Laminas\ConfigAggregator; use Laminas\Diactoros; use Mezzio; use Mezzio\ProblemDetails; -use Mezzio\Swoole; use Shlinkio\Shlink\Config\ConfigAggregator\EnvVarLoaderProvider; -use function class_exists; use function Shlinkio\Shlink\Config\env; -use function Shlinkio\Shlink\Config\openswooleIsInstalled; -use function Shlinkio\Shlink\Config\runningInRoadRunner; use function Shlinkio\Shlink\Core\enumValues; -use const PHP_SAPI; - $isTestEnv = env('APP_ENV') === 'test'; -$enableSwoole = PHP_SAPI === 'cli' && openswooleIsInstalled() && ! runningInRoadRunner(); return (new ConfigAggregator\ConfigAggregator( providers: [ @@ -30,9 +23,6 @@ return (new ConfigAggregator\ConfigAggregator( Mezzio\ConfigProvider::class, Mezzio\Router\ConfigProvider::class, Mezzio\Router\FastRouteRouter\ConfigProvider::class, - $enableSwoole && class_exists(Swoole\ConfigProvider::class) - ? Swoole\ConfigProvider::class - : new ConfigAggregator\ArrayProvider([]), ProblemDetails\ConfigProvider::class, Diactoros\ConfigProvider::class, Common\ConfigProvider::class, diff --git a/config/container.php b/config/container.php index e7574fe6..5d263173 100644 --- a/config/container.php +++ b/config/container.php @@ -12,17 +12,6 @@ chdir(dirname(__DIR__)); require 'vendor/autoload.php'; -// Workaround to make this compatible with both openswoole 22 and earlier versions. -// Openswoole support is deprecated. Remove in v4.0.0 -if (! function_exists('swoole_set_process_name')) { - // phpcs:disable - function swoole_set_process_name(string $name): void - { - OpenSwoole\Util::setProcessName($name); - } - // phpcs:enable -} - // This is one of the first files loaded. Configure the timezone here date_default_timezone_set(EnvVars::TIMEZONE->loadFromEnv(date_default_timezone_get())); diff --git a/config/test/test_config.global.php b/config/test/test_config.global.php index 8ae64d7a..0fed88ee 100644 --- a/config/test/test_config.global.php +++ b/config/test/test_config.global.php @@ -32,7 +32,6 @@ use function Laminas\Stratigility\middleware; use function Shlinkio\Shlink\Config\env; use function Shlinkio\Shlink\Core\ArrayUtils\contains; use function sprintf; -use function sys_get_temp_dir; use const ShlinkioTest\Shlink\API_TESTS_HOST; use const ShlinkioTest\Shlink\API_TESTS_PORT; @@ -136,20 +135,6 @@ return [ ], ], - 'mezzio-swoole' => [ - 'enable_coroutine' => false, - 'swoole-http-server' => [ - 'host' => API_TESTS_HOST, - 'port' => API_TESTS_PORT, - 'process-name' => 'shlink_test', - 'options' => [ - 'pid_file' => sys_get_temp_dir() . '/shlink-test-swoole.pid', - 'log_file' => __DIR__ . '/../../data/log/api-tests/output.log', - 'enable_coroutine' => false, - ], - ], - ], - 'routes' => !$isApiTest ? [] : [ [ 'name' => 'dump_coverage', diff --git a/data/infra/examples/shlink-daemon-logrotate.conf b/data/infra/examples/shlink-daemon-logrotate.conf deleted file mode 100644 index 2a11ed0b..00000000 --- a/data/infra/examples/shlink-daemon-logrotate.conf +++ /dev/null @@ -1,13 +0,0 @@ -/var/log/shlink/shlink_openswoole.log { - su root root - daily - missingok - rotate 120 - compress - delaycompress - notifempty - create 0640 root root - postrotate - /etc/init.d/shlink_openswoole restart - endscript -} diff --git a/data/infra/examples/shlink-daemon.sh b/data/infra/examples/shlink-daemon.sh deleted file mode 100644 index c32590f9..00000000 --- a/data/infra/examples/shlink-daemon.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: shlink_openswoole -# Required-Start: $local_fs $network $named $time $syslog -# Required-Stop: $local_fs $network $named $time $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Description: Shlink non-blocking server with openswoole -### END INIT INFO - -SCRIPT=/path/to/shlink/vendor/bin/laminas\ mezzio:swoole:start -RUNAS=root - -PIDFILE=/var/run/shlink_openswoole.pid -LOGDIR=/var/log/shlink -LOGFILE=${LOGDIR}/shlink_openswoole.log - -start() { - if [[ -f "$PIDFILE" ]] && kill -0 $(cat "$PIDFILE"); then - echo 'Shlink with openswoole already running' >&2 - return 1 - fi - echo 'Starting shlink with openswoole' >&2 - mkdir -p "$LOGDIR" - touch "$LOGFILE" - local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!" - su -c "$CMD" $RUNAS > "$PIDFILE" - echo 'Shlink started' >&2 -} - -stop() { - if [[ ! -f "$PIDFILE" ]] || ! kill -0 $(cat "$PIDFILE"); then - echo 'Shlink with openswoole not running' >&2 - return 1 - fi - echo 'Stopping shlink with openswoole' >&2 - kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE" - echo 'Shlink stopped' >&2 -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - *) - echo "Usage: $0 {start|stop|restart}" -esac diff --git a/data/infra/swoole.Dockerfile b/data/infra/swoole.Dockerfile deleted file mode 100644 index 4bc60385..00000000 --- a/data/infra/swoole.Dockerfile +++ /dev/null @@ -1,85 +0,0 @@ -FROM php:8.3-alpine3.19 -MAINTAINER Alejandro Celaya - -ENV APCU_VERSION 5.1.23 -ENV INOTIFY_VERSION 3.0.0 -ENV OPENSWOOLE_VERSION 22.1.2 -ENV PDO_SQLSRV_VERSION 5.12.0 -ENV MS_ODBC_DOWNLOAD 'b/9/f/b9f3cce4-3925-46d4-9f46-da08869c6486' -ENV MS_ODBC_SQL_VERSION 18_18.1.1.1 - -RUN apk update - -# Install common php extensions -RUN docker-php-ext-install pdo_mysql -RUN docker-php-ext-install calendar - -RUN apk add --no-cache oniguruma-dev -RUN docker-php-ext-install mbstring - -RUN apk add --no-cache sqlite-libs -RUN apk add --no-cache sqlite-dev -RUN docker-php-ext-install pdo_sqlite - -RUN apk add --no-cache icu-dev -RUN docker-php-ext-install intl - -RUN apk add --no-cache libzip-dev zlib-dev -RUN docker-php-ext-install zip - -RUN apk add --no-cache libpng-dev -RUN docker-php-ext-install gd - -RUN apk add --no-cache postgresql-dev -RUN docker-php-ext-install pdo_pgsql - -RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS linux-headers && \ - docker-php-ext-install sockets && \ - apk del .phpize-deps -RUN docker-php-ext-install bcmath - -# Install APCu extension -ADD https://pecl.php.net/get/apcu-$APCU_VERSION.tgz /tmp/apcu.tar.gz -RUN mkdir -p /usr/src/php/ext/apcu \ - && tar xf /tmp/apcu.tar.gz -C /usr/src/php/ext/apcu --strip-components=1 \ - && docker-php-ext-configure apcu \ - && docker-php-ext-install apcu \ - && rm /tmp/apcu.tar.gz \ - && rm /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini \ - && echo extension=apcu.so > /usr/local/etc/php/conf.d/20-php-ext-apcu.ini - -# Install inotify extension -ADD https://pecl.php.net/get/inotify-$INOTIFY_VERSION.tgz /tmp/inotify.tar.gz -RUN mkdir -p /usr/src/php/ext/inotify \ - && tar xf /tmp/inotify.tar.gz -C /usr/src/php/ext/inotify --strip-components=1 \ - && docker-php-ext-configure inotify \ - && docker-php-ext-install inotify \ - && rm /tmp/inotify.tar.gz - -# Install openswoole, pcov and mssql driver -RUN wget https://download.microsoft.com/download/${MS_ODBC_DOWNLOAD}/msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk && \ - apk add --allow-untrusted msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk && \ - apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \ - pecl install openswoole-${OPENSWOOLE_VERSION} pdo_sqlsrv-${PDO_SQLSRV_VERSION} pcov && \ - docker-php-ext-enable openswoole pdo_sqlsrv pcov && \ - apk del .phpize-deps && \ - rm msodbcsql${MS_ODBC_SQL_VERSION}-1_amd64.apk - -# Install composer -COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer - -# Make home directory writable by anyone -RUN chmod 777 /home - -VOLUME /home/shlink -WORKDIR /home/shlink - -# Expose openswoole port -EXPOSE 8080 - -CMD \ - # Install dependencies if the vendor dir does not exist - if [[ ! -d "./vendor" ]]; then /usr/local/bin/composer install ; fi && \ - # When restarting the container, openswoole might think it is already in execution - # This forces the app to be started every second until the exit code is 0 - until php ./vendor/bin/laminas mezzio:swoole:start; do sleep 1 ; done diff --git a/data/infra/swoole_proxy_vhost.conf b/data/infra/swoole_proxy_vhost.conf deleted file mode 100644 index af31b1ea..00000000 --- a/data/infra/swoole_proxy_vhost.conf +++ /dev/null @@ -1,14 +0,0 @@ -server { - listen 80 default_server; - - error_log /home/shlink/www/data/infra/nginx/swoole_proxy.error.log; - - location / { - proxy_http_version 1.1; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://shlink_swoole:8080; - proxy_read_timeout 90s; - } -} diff --git a/docker-compose.override.yml.dist b/docker-compose.override.yml.dist index 1c5409c6..a3af3546 100644 --- a/docker-compose.override.yml.dist +++ b/docker-compose.override.yml.dist @@ -7,12 +7,6 @@ services: - /etc/passwd:/etc/passwd:ro - /etc/group:/etc/group:ro - shlink_swoole: - user: 1000:1000 - volumes: - - /etc/passwd:/etc/passwd:ro - - /etc/group:/etc/group:ro - shlink_roadrunner: user: 1000:1000 volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 71194fbe..5416136d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,44 +39,6 @@ services: extra_hosts: - 'host.docker.internal:host-gateway' - shlink_swoole_proxy: - container_name: shlink_swoole_proxy - image: nginx:1.25-alpine - ports: - - "8002:80" - volumes: - - ./:/home/shlink/www - - ./data/infra/swoole_proxy_vhost.conf:/etc/nginx/conf.d/default.conf - links: - - shlink_swoole - - shlink_swoole: - container_name: shlink_swoole - build: - context: . - dockerfile: ./data/infra/swoole.Dockerfile - ports: - - "8080:8080" - - "9001:9001" - volumes: - - ./:/home/shlink - - ./data/infra/php.ini:/usr/local/etc/php/php.ini - links: - - shlink_db_mysql - - shlink_db_postgres - - shlink_db_maria - - shlink_db_ms - - shlink_redis - - shlink_redis_acl - - shlink_mercure - - shlink_mercure_proxy - - shlink_rabbitmq - - shlink_matomo - environment: - LC_ALL: C - extra_hosts: - - 'host.docker.internal:host-gateway' - shlink_roadrunner: container_name: shlink_roadrunner build: diff --git a/docker/README.md b/docker/README.md index 13de359d..55bd8876 100644 --- a/docker/README.md +++ b/docker/README.md @@ -5,7 +5,7 @@ This image provides an easy way to set up [shlink](https://shlink.io) on a container-based runtime. -It exposes a shlink instance served with [RoadRunner](https://roadrunner.dev) or [openswoole](https://openswoole.com/), which can be linked to external databases to persist data. +It exposes a shlink instance served with [RoadRunner](https://roadrunner.dev), which can be linked to external databases to persist data. ## Usage diff --git a/indocker b/indocker index 7cfbe2c3..f232b129 100755 --- a/indocker +++ b/indocker @@ -1,8 +1,8 @@ #!/usr/bin/env bash # Run docker containers if they are not up yet -if ! [[ $(docker ps | grep shlink_swoole) ]]; then +if ! [[ $(docker ps | grep shlink_roadrunner) ]]; then docker compose up -d fi -docker exec -it shlink_swoole /bin/sh -c "$*" +docker exec -it shlink_roadrunner /bin/sh -c "$*" diff --git a/module/Core/config/event_dispatcher.config.php b/module/Core/config/event_dispatcher.config.php index 012b8e12..8fc534d4 100644 --- a/module/Core/config/event_dispatcher.config.php +++ b/module/Core/config/event_dispatcher.config.php @@ -20,7 +20,6 @@ use Shlinkio\Shlink\IpGeolocation\GeoLite2\DbUpdater; use Shlinkio\Shlink\IpGeolocation\GeoLite2\GeoLite2Options; use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface; -use function Shlinkio\Shlink\Config\runningInOpenswoole; use function Shlinkio\Shlink\Config\runningInRoadRunner; return (static function (): array { @@ -47,7 +46,7 @@ return (static function (): array { ]; // Send visits to matomo asynchronously if the runtime allows it - if (runningInRoadRunner() || runningInOpenswoole()) { + if (runningInRoadRunner()) { $asyncEvents[EventDispatcher\Event\VisitLocated::class][] = EventDispatcher\Matomo\SendVisitToMatomo::class; } else { $regularEvents[EventDispatcher\Event\VisitLocated::class] = [EventDispatcher\Matomo\SendVisitToMatomo::class]; diff --git a/module/Core/src/ShortUrl/UrlShortener.php b/module/Core/src/ShortUrl/UrlShortener.php index 7bb74ba6..0305f936 100644 --- a/module/Core/src/ShortUrl/UrlShortener.php +++ b/module/Core/src/ShortUrl/UrlShortener.php @@ -57,7 +57,7 @@ class UrlShortener implements UrlShortenerInterface $this->eventDispatcher->dispatch(new ShortUrlCreated($newShortUrl->getId())); } catch (ContainerExceptionInterface $e) { // Ignore container errors when dispatching the event. - // When using openswoole, this event will try to enqueue a task, which cannot be done outside an HTTP + // When using RoadRunner, this event will try to enqueue a task, which cannot be done outside an HTTP // request. // If the short URL is created from CLI, the event dispatching will fail. return UrlShorteningResult::withErrorOnEventDispatching($newShortUrl, $e);