英文:
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 >/etc/systemd/system/supervisord.service.d/supervisord.conf<<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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论