name = 'Http Server Worker'; // 启动4个进程对外提供服务 $http_worker->count = 2; // 接收到浏览器发送的数据时回复数据给浏览器 $http_worker->onMessage = function ($connection,$request) { $t1 = microtime(true); $response = \app\helper\Router::process($request); $t2 = microtime(true); $time = round($t2 - $t1, 3); $mem = memory_get_usage() / (1.0 * 1024 * 1024); $response->withHeaders([ 'X-Time' => $time .'ms', 'X-Memory' => ceil($mem).'MB' ]); $connection->send($response); }; // 运行worker Worker::runAll();