diff --git a/.docker/etc/supervisor/supervisord.conf b/.docker/etc/supervisor/supervisord.conf index 7a1ab26..018e54b 100644 --- a/.docker/etc/supervisor/supervisord.conf +++ b/.docker/etc/supervisor/supervisord.conf @@ -5,6 +5,23 @@ logfile=/dev/null logfile_maxbytes=0 pidfile=/tmp/supervisord.pid +[unix_http_server] +file=/run/supervisord.sock +chmod=0700 + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[program:chown] +directory=/www +command=sh -c "chown -R www:www /www && chmod -R 775 /www" +autostart=true +autorestart=false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + [program:nginx] command=nginx -g 'daemon off;' user=root @@ -51,7 +68,7 @@ stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 autostart=true autorestart=true -startretries=3 +startretries=10 [program:xboard-queue] command=php artisan horizon @@ -64,4 +81,3 @@ stderr_logfile_maxbytes=0 autostart=true autorestart=true startretries=10 -numprocs=1 diff --git a/Dockerfile b/Dockerfile index d14b1a8..4e81d3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ RUN composer install --optimize-autoloader --no-cache --no-dev \ && chown -R www:www /www \ && chmod -R 775 /www -CMD chown -R www:www /www ; chmod -R 775 /www ; /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf \ No newline at end of file +CMD /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf \ No newline at end of file diff --git a/webman.php b/webman.php index 96e44ec..3c3e362 100644 --- a/webman.php +++ b/webman.php @@ -4,11 +4,12 @@ require_once __DIR__ . '/vendor/autoload.php'; use Adapterman\Adapterman; use Workerman\Worker; + Adapterman::init(); -$http_worker = new Worker('http://127.0.0.1:7010'); -$http_worker->count = getenv('WEBMAN_WORKERS') ?: (swoole_cpu_num() ?: 1); -$http_worker->name = 'AdapterMan'; +$http_worker = new Worker('http://127.0.0.1:7010'); +$http_worker->count = getenv('WEBMAN_WORKERS') ?: max(swoole_cpu_num(), 2); +$http_worker->name = 'AdapterMan'; $http_worker->onWorkerStart = static function () { //init(); @@ -17,7 +18,12 @@ $http_worker->onWorkerStart = static function () { $http_worker->onMessage = static function ($connection, $request) { + static $request_count; + $connection->send(run()); + if (++$request_count > 10000) { + Worker::stopAll(); + } }; Worker::runAll();