Supervisor open file limit won't change when using Chef
Asked Answered
M

4

5

I am modifying /etc/security/limits.conf on the machine, and then installing Supervisor in a Chef recipe. After the recipe run finishes, if I run cat /proc/<process id>/limits I see:

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

If I log into the machine and run service supervisor restart, the max open files is then set correctly. However, if I run this command in the recipe (right after installing supervisor, at the very end of the recipe, anything) the limit does not change. It is not until I log in and manually run that command that the limit changes.

How can I get the open file limit for supervisor to change using the chef recipe? Operating system is Ubuntu 12.04.

Mathews answered 13/1, 2015 at 23:35 Comment(0)
B
11

To any weary googlers: you might be looking for the minfds setting in the supervisor config. This setting seems to take effect for both the supervisord process as well as the children. I had a number of other strategies, including launching a shell script that set the limits before executing the actual program, but this was the only thing that worked.

Benioff answered 8/4, 2015 at 22:52 Comment(5)
minfds only defines the minimum of file descriptors the supervisord process has access to. If less then the specified value, supervisord will not startup. it will not set the allowed files to open for the children ...Mezereon
so in the config file for the program set minfds = 100000 or what not?Crush
@Mezereon "A call to setrlimit will be made to attempt to raise the soft and hard limits of the supervisord process to satisfy minfds. The hard limit may only be raised if supervisord is run as root."Rosa
Stack is amazing, you are amazing, the comments are amazing !Multitude
don't forget to sudo service supervisor restartHypoplasia
M
4

Supervisor relies at its service config. So to raise limit you need to do it at service level.

This scenario works perfect for ubuntu 20.04

  1. systemctl edit supervisor.service

  2. Enter and save

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

  2. systemctl restart supervisor

Then, just to check, cat /proc/pgrep supervisor/limits | grep open

You will se something like

Max open files            20000                20000                files

It works :)

Monteria answered 3/12, 2021 at 6:5 Comment(0)
I
0

I did not test on my pc because I cannot stop supervisord now. But if you reorder the /etc/rc directory?

# 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

I have the same problem Supervisord and ulimit to java app

Imponderabilia answered 19/1, 2015 at 19:2 Comment(0)
F
0

The implementation of supervisor is such that a process can be started as a non-root user, with more privileges than that user is allowed - bypassing pam, limits.conf, etc. So I doubt that this problem will be fixed. Have a look at https://github.com/Supervisor/supervisor/pull/229

Frieda answered 22/3, 2017 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.