From c50b5ea5f663186bf86151d8cfae4ec4a231beda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=8F=E5=9F=B9?= Date: Wed, 30 Nov 2022 14:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81php8=E5=92=8Cswoole=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 111 +++------------------------------------- composer.json | 12 ++--- src/Command/Command.php | 1 + src/Process.php | 2 +- 4 files changed, 14 insertions(+), 112 deletions(-) diff --git a/Dockerfile b/Dockerfile index f4d111c..76b4e4a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,112 +1,13 @@ -FROM alpine:3.9 +# FROM phpswoole/swoole:4.8-php7.4-alpine +FROM phpswoole/swoole:latest -LABEL maintainer="Swoole Jobs " version="1.0" license="MIT" +LABEL maintainer="Swoole Jobs " version="1.1" license="MIT" -## -# ---------- building ---------- -## -RUN set -ex \ - # change apk source repo - && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories \ - && apk update \ - && apk add --no-cache \ - # Install base packages ('ca-certificates' will install 'nghttp2-libs') - ca-certificates \ - curl \ - wget \ - tar \ - xz \ - libressl \ - tzdata \ - pcre \ - php7 \ - php7-pecl-amqp \ - php7-bcmath \ - php7-curl \ - php7-ctype \ - php7-dom \ - php7-fileinfo \ - php7-gd \ - php7-iconv \ - php7-json \ - php7-mbstring \ - php7-mysqlnd \ - php7-openssl \ - php7-pdo \ - php7-pdo_mysql \ - php7-pdo_sqlite \ - php7-phar \ - php7-posix \ - php7-redis \ - php7-simplexml \ - php7-sockets \ - php7-sodium \ - php7-sysvshm \ - php7-sysvmsg \ - php7-sysvsem \ - php7-tokenizer \ - php7-zip \ - php7-zlib \ - php7-xml \ - php7-xmlreader \ - php7-xmlwriter \ - php7-pcntl \ - && apk del --purge *-dev \ - && rm -rf /var/cache/apk/* /tmp/* /usr/share/man /usr/share/php7 \ - && php -v \ - && php -m -ARG swoole +RUN docker-php-ext-install amqp -## -# ---------- env settings ---------- -## -ENV SWOOLE_VERSION=${swoole:-"4.4.3"} \ - # install and remove building packages - PHPIZE_DEPS="autoconf dpkg-dev dpkg file g++ gcc libc-dev make php7-dev php7-pear pkgconf re2c pcre-dev zlib-dev libtool automake" - -# update -RUN set -ex \ - && apk update \ - # for swoole extension libaio linux-headers - && apk add --no-cache libstdc++ openssl git bash \ - && apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libaio-dev openssl-dev \ - # download - && cd /tmp \ - && curl -SL "https://github.com/swoole/swoole-src/archive/v${SWOOLE_VERSION}.tar.gz" -o swoole.tar.gz \ - && ls -alh \ - # php extension:swoole - && cd /tmp \ - && mkdir -p swoole \ - && tar -xf swoole.tar.gz -C swoole --strip-components=1 \ - && ( \ - cd swoole \ - && phpize \ - && ./configure --enable-mysqlnd --enable-openssl \ - && make -s -j$(nproc) && make install \ - ) \ - && printf "extension=swoole.so\n\ - swoole.use_shortname = 'Off'\n\ - swoole.enable_coroutine = 'Off'\n\ - " >/etc/php7/conf.d/swoole.ini \ - # clear - && php -v \ - && php -m \ - && php --ri swoole \ - # ---------- clear works ---------- - && apk del .build-deps \ - && rm -rf /var/cache/apk/* /tmp/* /usr/share/man - -RUN printf "# composer php cli ini settings\n\ +RUN printf "# php cli ini settings\n\ date.timezone=PRC\n\ memory_limit=-1\n\ - " > /etc/php7/php.ini -ENV COMPOSER_ALLOW_SUPERUSER 1 -ENV COMPOSER_HOME /tmp -ENV COMPOSER_VERSION 1.9.0 - -RUN curl -SL "https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar" -o composer.phar \ - && mv composer.phar /usr/bin/composer \ - && chmod u+x /usr/bin/composer \ - && echo -e "\033[42;37m Build Completed :).\033[0m\n" \ No newline at end of file + " >> /usr/local/etc/php/conf.d/php.ini diff --git a/composer.json b/composer.json index 4dd5fd1..8ab482d 100644 --- a/composer.json +++ b/composer.json @@ -5,13 +5,13 @@ "homepage": "https://github.com/kcloze/swoole-jobs", "license": "MIT", "require": { - "php": ">=7.0", - "ext-swoole": ">=1.8.9", + "php": ">=8.0", + "ext-swoole": ">=4.8", "ext-redis": "*", - "symfony/console": "^3.4", - "bramus/router": "^1.3", - "guzzlehttp/guzzle": "^6.3", - "enqueue/amqp-ext": "^0.8" + "symfony/console": "^6.1", + "bramus/router": "^1.6", + "guzzlehttp/guzzle": "^7.5" + }, "require-dev": { "phpunit/phpunit": "^4.8.35 || ^5.7" diff --git a/src/Command/Command.php b/src/Command/Command.php index 031490a..253def8 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->printHelpMessage(); break; } + return 0; } abstract protected function start(); diff --git a/src/Process.php b/src/Process.php index 37ad62f..b24bfe7 100644 --- a/src/Process.php +++ b/src/Process.php @@ -156,7 +156,7 @@ public function reserveQueue($num, $topic, $type=self::CHILD_PROCESS_CAN_RESTART unset($num, $topic, $type); }); - $this->disableCoroutine($reserveProcess); + //$this->disableCoroutine($reserveProcess); $pid = $reserveProcess->start(); $this->workers[$pid] = $reserveProcess;