on('Request', $vega->handler()); $http->on('WorkerStart', function ($server, $workerId) { // swoole 协程不支持 set_exception_handler 需要手动捕获异常 try { // App\Container\DB::enableCoroutine(); } catch (\Throwable $ex) { App\Error::handle($ex); } }); $http->set([ 'worker_num' => swoole_cpu_num() * 4, 'enable_coroutine' => false, 'open_tcp_nodelay' => true, 'max_request' => 0, 'log_file' => '/dev/null', 'log_level' => SWOOLE_LOG_ERROR, ]); Logger::instance()->info('Start swoole server'); $http->start();