mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
chore: 优化docker环境下的启动速度,增加webman进程自动重启来释放内存
This commit is contained in:
parent
fa6dfc6acb
commit
227f50b9d1
@ -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
|
||||
|
@ -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
|
||||
CMD /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf
|
12
webman.php
12
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();
|
||||
|
Loading…
Reference in New Issue
Block a user