From 50c412ca0e61f6b56f14f92ffd891d7462cfacc9 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Fri, 1 Sep 2023 14:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BF=BD=E7=95=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - config/swoole.php | 116 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 config/swoole.php diff --git a/.gitignore b/.gitignore index 95aa6553..be8fa6f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,3 @@ public/protocol.html runtime/* cert_crmeb copy.key dump.rdb -config/swoole.php diff --git a/config/swoole.php b/config/swoole.php new file mode 100644 index 00000000..34e2ad4d --- /dev/null +++ b/config/swoole.php @@ -0,0 +1,116 @@ + +// +---------------------------------------------------------------------- + + +use app\webscoket\Manager; +use Swoole\Table; +use think\swoole\websocket\socketio\Parser; + +return [ + 'server' => [ + 'host' => env('SWOOLE_HOST', '0.0.0.0'), // 监听地址 + 'port' => env('SWOOLE_PORT', 8325), // 监听端口 + 'mode' => SWOOLE_PROCESS, // 运行模式 默认为SWOOLE_PROCESS + 'sock_type' => SWOOLE_SOCK_TCP, // sock type 默认为SWOOLE_SOCK_TCP + 'options' => [ + 'pid_file' => runtime_path() . 'swoole.pid', + 'log_file' => runtime_path() . 'swoole.log', + 'daemonize' => false, + // Normally this value should be 1~4 times larger according to your cpu cores. + 'reactor_num' => swoole_cpu_num(), + 'worker_num' => swoole_cpu_num(), + 'task_worker_num' => swoole_cpu_num(), + 'task_enable_coroutine' => false, + 'task_max_request' => 2000, + 'enable_static_handler' => true, + 'document_root' => root_path('public'), + 'package_max_length' => 50 * 1024 * 1024, + 'buffer_output_size' => 10 * 1024 * 1024, + 'socket_buffer_size' => 128 * 1024 * 1024, + 'max_request' => 3000, + 'send_yield' => true, + 'reload_async' => true, + ], + ], + 'websocket' => [ + 'enable' => true, + 'handler' => Manager::class, + 'parser' => Parser::class, + 'ping_interval' => 25000, //1000 = 1秒 + 'ping_timeout' => 60000, //1000 = 1秒 + 'room' => [ + 'type' => 'table', + 'table' => [ + 'room_rows' => 4096, + 'room_size' => 2048, + 'client_rows' => 8192, + 'client_size' => 2048, + ], + 'redis' => [ + + ], + ], + 'listen' => [], + 'subscribe' => [], + ], + 'rpc' => [ + 'server' => [ + 'enable' => false, + 'port' => 9000, + 'services' => [ + ], + ], + 'client' => [ + ], + ], + 'hot_update' => [ + 'enable' => env('APP_DEBUG', false), + 'name' => ['*.php'], + 'include' => [app_path(),root_path().'crmeb'], + 'exclude' => [], + ], + //连接池 + 'pool' => [ + 'db' => [ + 'enable' => true, + 'max_active' => 3, + 'max_wait_time' => 5, + ], + 'cache' => [ + 'enable' => true, + 'max_active' => 3, + 'max_wait_time' => 5, + ], + ], + 'coroutine' => [ + 'enable' => false, + 'flags' => SWOOLE_HOOK_ALL, + ], + 'tables' => [ + 'user' => [ + 'size' => 204800, + 'columns' => [ + ['name' => 'fd', 'type' => Table::TYPE_INT], + ['name' => 'type', 'type' => Table::TYPE_INT], + ['name' => 'uid', 'type' => Table::TYPE_INT] + ] + ] + ], + //每个worker里需要预加载以共用的实例 + 'concretes' => [], + //重置器 + 'resetters' => [], + //每次请求前需要清空的实例 + 'instances' => [], + //每次请求前需要重新执行的服务 + 'services' => [], + 'locks' => ['group_buying'], +];