Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supervisor open file limit won't change when using Chef

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.

like image 541
Brad Avatar asked Dec 25 '22 00:12

Brad


2 Answers

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 :)

like image 35
Александр Сорокин Avatar answered Dec 27 '22 13:12

Александр Сорокин


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.

like image 67
Dan Avatar answered Dec 27 '22 12:12

Dan