Linux – ubuntu upstart – how to set global nofile limit

linuxUbuntuupstart

ubuntu 12.04

I have change the setting:

 /etc/security/limits.conf
 *               soft    nofile          65000
 *               hard    nofile          65000

but cat /proc/{PID}/limits:

Limit                     Soft Limit           Hard Limit           Units     
Max open files            1024                 4096                 files 

I found the problem. Upstart has a bug that causes it to ignore limits set in /etc/security/limits.conf. These links describe the bug and a workaround.

Now the question is, how to set a global nofile limit because i don't want to set nofile limit in every upstart script which i need.

Thanks.

Best Answer

The Upstart behavior is as specified and is not a bug - services are bound by their own configuration and not by the security limits (which bind user processes for which there is no other definition - hence why it is security limits).

There was some work done to implement a "global configuration" defaults file for Upstart but that seems to have been neglected (possibly due to non-commitment from Upstart developers).

IMO your best choice is to create an override file with just the limit nofile directive and copy it to override all existing upstart services. Something like this:

for file in /etc/init/*.conf
  do echo "limit nofile 65000 65000" > "${file%%.conf}.override"
done