ubuntu系統(tǒng)
Warning: file_put_contents(/xxxx/log//17-03-22.txt): failed to open stream: Too many open files in /xxx/common/function.php on line 323
這是方法是寫日志,用的是file_put_contents方法,按理說寫完日志就關掉了文件連接了,而我的work就看了3個進程,就導致了這個問題,請問如何解決?
調(diào)試發(fā)現(xiàn)是curl_init造成的,但是有關閉,系統(tǒng)卻一直保持連接
protected function _wget($url, $post_data = null)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
if ($post_data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
if ($response === false) {
system_log('獲取遠程數(shù)據(jù)失?。? . curl_error($ch));
curl_close($ch);
return false;
}
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_code == 200) {
$ret = json_decode($response, true);
if ($ret) {
return $ret;
}
system_log('獲取遠程數(shù)據(jù)返回異常內(nèi)容:' . $response);
} else {
system_log('獲取遠程數(shù)據(jù)返回異常狀態(tài)碼:' . $http_code . ',返回內(nèi)容為:' . $response);
return false;
}
}
http://php.net/manual/en/function.curl-setopt.php
這里有curl選項,應該有強制關閉復用鏈接的選項,找下