duanjian7617 2014-08-01 10:27
浏览 8
已采纳

具有内置Web搜寻器的Martini Go服务器在几个小时后会获得太多打开的文件

I built a web crawler that serves up some http info on its findings. The crawler runs as a go routine and martini runs the web server. After a while I start getting

2014/08/01 10:23:51 http: Accept error: accept tcp [::]:3000: too many open files; retrying in 1s.

I read I should try increasing the max open files only I am new to this level of configuration and have no idea how to do this. I am running this on Ubuntu 14.04. How do you change a martini servers max open files please and thank you.

  • 写回答

2条回答 默认 最新

  • dongsi7759 2014-08-01 10:38
    关注

    Make sure you don't forget to close the response you get from an http.Get, as in this issue.

    This example shows a better response management:

        resp, _ := http.Get("http://127.0.0.1:3000"+path)
        s, _ := ioutil.ReadAll(resp.Body)
        resp.Body.Close()
    

    If the issue really still persists, then you can try and increase the fs.file-max in /etc/sysctl.conf.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动