ulimit in the ubuntu package

Sergey Budnevitch sb at waeme.net
Tue Jun 4 13:25:09 UTC 2013


On 4  Jun2013, at 17:04 , pablo platt <pablo.platt at gmail.com> wrote:

> It's not clear to me how worker_rlimit_nofile, /etc/security/limits.conf and setting ulimit in the init.d script are related.
> 
> Is worker_rlimit_nofile the same as using ulimit in the init.d script?
> Or does ulimit sets the maximum limit and worker_rlimit_nofile the limit per worker?

All of them set RLIMIT_NOFILE (man 2 setrlimit). 
If there is worker_rlimit_nofile directive in nginx.conf, nginx master process
sets RLIMIT_NOFILE for new workers processes. This works no matter how
you start nginx.
ulimit -n in init script will works if nginx is started by init script.
limits.conf is used by pam_limits, so it works for:
% grep pam_limits /etc/pam.d/*
/etc/pam.d/atd:session    required   pam_limits.so
/etc/pam.d/cron:session    required   pam_limits.so
/etc/pam.d/login:session    required   pam_limits.so
/etc/pam.d/sshd:session    required     pam_limits.so
/etc/pam.d/su:# session    required   pam_limits.so

atd, cron, login, sshd processes and their child processes,
for example when you login locally or via ssh.


> 
> Why does the init.d script from the ubuntu repo let me set using ulimit while the package from nginx.org doesn't?
> https://gist.github.com/aganov/1121022#file-nginx-L43
> 
> Does /etc/security/limits.conf has any effect on the nofile limit in nginx when it is started using init.d script?
> For upstart, I know that you have to set the limit in the upstart script and can't use /etc/security/limits.conf

limits.conf will not work if init script is started on system boot.


> 
> 
> On Tue, Jun 4, 2013 at 3:39 PM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Hello!
> 
> On Tue, Jun 04, 2013 at 04:30:40PM +0400, Sergey Budnevitch wrote:
> 
> >
> > On 4  Jun2013, at 15:39 , pablo platt <pablo.platt at gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I'm using the ubuntu package from nginx.org.
> > >
> > > In the package from the official ubuntu repo, you can set file descriptor limit by changing /etc/default/nginx
> > > # Check if the ULIMIT is set in /etc/default/nginx
> > > if [ -n "$ULIMIT" ]; then
> > >     # Set the ulimits
> > >     ulimit $ULIMIT
> > > fi
> >
> > ulimit without flags sets max file size in blocks, not file descriptor limit, so
> > you may fill a bug in their bug tracker.
> 
> I think the expected use is to supply arguments within the ULIMIT
> variable.
> 
> --
> Maxim Dounin
> http://nginx.org/en/donation.html
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list