我构建了一个网络爬虫,提供一些有关其发现的 http 信息。爬虫作为 go routine 运行,martini 运行 web 服务器。过了一会儿,我开始得到
2014/08/01 10:23:51 http: Accept error: accept tcp [::]:3000: too many open files; retrying in 1s.
我读到我应该尝试增加最大打开文件数我只是这个配置级别的新手并且不知道如何做到这一点。我在 Ubuntu 14.04 上运行它。请问如何更改 martini 服务器的最大打开文件数,谢谢。
请您参考如下方法:
确保不要忘记关闭从 http.Get 获得的响应,如 this issue .
This example显示更好的响应管理:
resp, _ := http.Get("http://127.0.0.1:3000"+path)
s, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
如果问题仍然存在,那么您可以 try and increase the fs.file-max in /etc/sysctl.conf .






