mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-14 19:40:53 +08:00
chore: 优化docker环境下的启动速度,增加webman进程自动重启来释放内存
This commit is contained in:
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();
|
||||
|
||||
Reference in New Issue
Block a user