使用 Chef 时主管打开文件限制不会改变

Supervisor open file limit won't change when using Chef

我正在修改机器上的 /etc/security/limits.conf,然后在 Chef 配方中安装 Supervisor。在食谱 运行 完成后,如果我 运行 cat /proc/<process id>/limits 我看到:

Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max open files            1024                 4096                 files

如果我登录到机器并且 运行 service supervisor restart,则最大打开文件设置正确。但是,如果我 运行 配方中的这个命令(在安装 supervisor 之后,在配方的最后,任何东西)限制都不会改变。直到我登录并手动 运行 命令限制才改变。

如何让主管使用厨师食谱更改打开文件限制?操作系统是 Ubuntu 12.04.

我没有在我的电脑上测试,因为我现在无法停止 supervisord。但是,如果您重新排序 /etc/rc 目录?

# find /etc/rc* -iname "*super*"
/etc/rc0.d/K01supervisor
/etc/rc1.d/K01supervisor
/etc/rc2.d/S16supervisor
/etc/rc3.d/S16supervisor
/etc/rc4.d/S16supervisor
/etc/rc5.d/S16supervisor
/etc/rc6.d/K01supervisor

我有同样的问题Supervisord and ulimit to java app

致所有疲惫的 google 用户:您可能正在寻找 the supervisor config 中的 minfds 设置。此设置似乎对监督进程和子进程都有效。我有许多其他策略,包括启动 shell 脚本以在执行实际程序之前设置限制,但这是唯一有效的方法。

supervisor 的实现使得一个进程可以作为非 root 用户启动,拥有比该用户更多的权限——绕过 pam、limits.conf 等。所以我怀疑这个问题将被修复。看看https://github.com/Supervisor/supervisor/pull/229

Supervisor 依赖其服务配置。因此,要提高限制,您需要在服务级别进行。

这个场景非常适合 ubuntu 20.04

  1. systemctl 编辑 supervisor.service

  2. 输入并保存

[Service]
LimitNOFILE=20000
  1. systemctl daemon-reload

  2. systemctl 重启主管

然后,只是为了检查,cat /proc/pgrep supervisor/limits | grep 打开

你会看到类似的东西

Max open files            20000                20000                files

有效:)