增加进程的打开文件限制

huangapple go评论84阅读模式
英文:

Increase open files limit for process

问题

当我运行ulimit -n时,返回的值是100000

我已经在/etc/security/limits.conf中添加了以下行:

*     soft    nofile          100000
*     hard    nofile          100000

我还编辑了pan_limits

但是,我目前正在运行一个不断抛出错误的Go程序:

2016/03/09 21:42:27 http: Accept error: accept tcp [::]:3000: accept4: too many open files; retrying in 5ms
2016/03/09 21:42:27 getAudioOnlyInfo: open /dev/null: too many open files

问题是,当我通过运行cat /proc/1480/limits来检查实际进程上设置的限制时,我看到的是:

Max open files            1024                 4096                 files   

我通过supervisor运行一个Golang程序,它为什么不读取系统限制呢?

英文:

When I run ulimit -n I get 100000 as the value.

I have edited the Added following lines in /etc/security/limits.conf

*     soft    nofile          100000
*     hard    nofile          100000

I have also edited the pan_limits

But I am currently running a go program that keeps throwing out the error

2016/03/09 21:42:27 http: Accept error: accept tcp [::]:3000: accept4: too many open files; retrying in 5ms
2016/03/09 21:42:27 getAudioOnlyInfo: open /dev/null: too many open files

The issue is that when I actually check to see the limits set on the actual process by running cat /proc/1480/limits I see this

Max open files            1024                 4096                 files   

I'm running a golang program through supervisor is there a reason it wouldn't be reading the system limits?

答案1

得分: 3

在尝试解决这个问题的多个问题后,发现主管程序在程序上设置了自己的文件限制。如评论中所示,您必须在supervisor中使用minfds设置。

要检查它是否起作用,您可以运行cat /proc/$PID/limits命令。

这应该输出您设置的minfds的数字,对我来说是100,000。

Max open files            100000               100000               files     

我想指出,当您将minfds放入supervisor时,您应该将其放在/etc/supervisor/supervisord.conf中,如果将其放在程序的配置文件中,它将无效。

英文:

After trying to resolve this issue in multiple questions, got it down to the fact that supervisor set's its own file limit on the program. As seen in the comments, you have to use minfds setting in supervisor.

To check to see if it is working you can run a cat /proc/$PID/limits

Which should output the number you set minfds too, in my case 100,000

Max open files            100000               100000               files     

I would like to note that when you go and put into supervisor the minfds you put it in the /etc/supervisor/supervisord.conf as if you put in your programs config file it will do nothing.

答案2

得分: 0

这可能会对你有所帮助:

mkdir -p /etc/systemd/system/supervisord.service.d
cat >/etc/systemd/system/supervisord.service.d/supervisord.conf<<EOF
[Service]
LimitNOFILE=65535
LimitNPROC=65535
EOF

systemctl daemon-reload
systemctl restart supervisord

请注意,这是一段代码,用于创建目录、编辑配置文件并重新加载和重启 supervisord 服务。

英文:

This might help you

mkdir -p /etc/systemd/system/supervisord.service.d
cat &gt;/etc/systemd/system/supervisord.service.d/supervisord.conf&lt;&lt;EOF
[Service]
LimitNOFILE=65535
LimitNPROC=65535
EOF

systemctl daemon-reload
systemctl restart supervisord

答案3

得分: 0

/etc/supervisor/supervisord.conf文件中,需要添加以下参数:

minfds = 2048(在我的情况下是2048,您可以根据您的需求设置)

增加进程的打开文件限制

这是因为supervisor在程序中设置了自己的文件限制。您必须在supervisor中使用minfds设置。要检查它是否起作用,您可以运行cat /proc/$PID/limits命令。

有关minfds的更多详细信息,请参阅:http://supervisord.org/configuration.html#supervisord-section-values

英文:

In /etc/supervisor/supervisord.conf file, following parameter needs to be added:

minfds = 2048 (in my case it was 2048, you may set this as per your requirement)

增加进程的打开文件限制

It is because supervisor set's its own file limit on the program. You have to use minfds setting in supervisor. To check to see if it is working you can run a cat /proc/$PID/limits command.

More details about minfds here: http://supervisord.org/configuration.html#supervisord-section-values

huangapple
  • 本文由 发表于 2016年3月10日 04:46:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/35902235.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定