myodcq
Last Updated: February 25, 2016
·
8.205K
· rparet
3f078a22c56a94836c776ee986de090e

Setting max file descriptors and other limits with upstart on debian/ubuntu

Out of file descriptors?

If you run service jobs (daemons and the like) via upstart on debian/ubuntu you may have run into a problem where they don't inherit the settings you'd expect from ulimit / limits.conf on your box.

You may be googling and getting advice like making sure you have the right settings in /etc/security/limits.conf and making sure that session required pam_limits.so is in /etc/pam.d/common-session{,-noninteractive}.

This advice is solid for processes spawned interactively and those run from SysV init (/etc/init.d/...) however Upstart does not respect /etc/security/limits.conf or anything related to PAM by design.

Solution: Set your limits explicitly in Upstart

If you want to set limits for processes managed by Upstart, you have to do it explicitly in the Upstart config.

For example:

#
description "my service"
start on startup
stop on shutdown
# set max file descriptors to 65536 (soft/hard)
limit nofile 65536 65536

script
/path/to/my/script
end script

Hopefully this saves you a few hours of frustation when your upstart-managed process runs out of file descriptors for the first time!

Say Thanks
Respond

2 Responses
Add your response

11828
E25a7256115d3f1eac5f1ccd29eda7d1

It works for my elasticsearch setup as well, thanks

over 1 year ago ·
20322
681843573f794800a9a19b0957b37c98

This was really helpful! Thanks.

over 1 year ago ·
Filed Under