- 问题:在workerman系统执行一段时间会出现进程busy情况
- 查找原因,可以看到一个fd出现异常
strace -ttp 25308
lsof -nPp 25308
查看进程执行的描述,发现是执行了一个http请求,是一个请求长时间不返回导致的阻塞,这里需要对请求进行超时时间的设置
这里使用了GuzzleHttp拓展包,设置方式
- 方式一
$client = new Client([
'timeout' => 2.0,
]);
- 方式二
$client = new Client();
$res = $client->request('GET', $url, ['timeout' =>2.0]);