Subject: Re: managing process memory limits on the fly?
To: None <netbsd-users@netbsd.org>
From: Gary Duzan <gary@duzan.org>
List: netbsd-users
Date: 02/21/2007 22:49:59
Simon Burge wrote:
> Carl Brewer wrote:
>
>> I had a look, zope does the exec/change user thing internally, and
>> I really don't want to go mucking in its bowels. So I have set a
>> ulimit in the zope process control script as follows (for the
>> archive) :
>>
>> /home/zope/server/bin/zopectl #! /bin/sh
>>
>> # let zope use 356MB ulimit -d 393216
>
> In the vein of "there's many ways to skin a cat", if you're using a
> normal /etc/rc.d script to control zope, you could add a
> "/etc/rc.conf.d/zope" that just contains
>
> # let zope use 356MB ulimit -d 393216
>
> and that would changes limits for just things started by
> /etc/rc.d/zope.
For an additional cat-skinning option, since we're talking Zope, and
therefore Python, you could also find a convenient place in some Python
code to play with the limits. For example:
capo { ~ } % python2.4
Python 2.4.3 (#1, Sep 30 2006, 23:07:14)
[GCC 4.1.2 20060628 prerelease (NetBSD nb2 20060711)] on netbsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import resource dir(resource)
['RLIMIT_CORE', 'RLIMIT_CPU', 'RLIMIT_DATA', 'RLIMIT_FSIZE',
'RLIMIT_MEMLOCK', 'RLIMIT_NOFILE', 'RLIMIT_NPROC', 'RLIMIT_RSS',
'RLIMIT_STACK', 'RLIM_INFINITY', 'RUSAGE_CHILDREN', 'RUSAGE_SELF',
'__doc__', '__file__', '__name__', 'error', 'getpagesize', 'getrlimit',
'getrusage', 'setrlimit', 'struct_rusage']
>>> print resource.getrlimit.__doc__
None
>>> resource.getrlimit(resource.RLIMIT_DATA)
(268435456, 8589934592)
>>> resource.setrlimit(resource.RLIMIT_DATA, 268435456 * 2)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: setrlimit() argument 2 must be 2-item sequence, not int
>>> resource.setrlimit(resource.RLIMIT_DATA, (268435456 * 2,
>>> 8589934592)) resource.getrlimit(resource.RLIMIT_DATA)
(536870912, 8589934592)
>>>
Good luck...
Gary Duzan