[Zope-Checkins] CVS: Zope - z2.py:1.55.10.1
Chris McDonough
chrism@zope.com
Sun, 30 Sep 2001 03:08:25 -0400
Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv6748
Modified Files:
Tag: chrism-setrlimit-branch
z2.py
Log Message:
Make necessary changes to be able to specify rlimit of mem size on command line at start time.
=== Zope/z2.py 1.55 => 1.55.10.1 ===
may increase performance in your particular environment.
+ -H n
+
+ Linux only! This option is ignored on windows and other versions of
+ UNIX.
+
+ Set the maximum process size limit. This integer value determines
+ the size in bytes to which the Zope process may grow. When the
+ limit is reached, a MemoryError is raised and Zope will attempt to
+ restart if the system is under daemon (-Z) control. If the system
+ is not under daemon control, Zope will attempt to shut itself
+ down. When the process restarts, an event is written to the log
+ file. The default is %(RLIMIT_MEM)s.
+
-D
Run in Zope debug mode. This causes the Zope process not to
@@ -374,6 +387,9 @@
# Detailed log file
DETAILED_LOG_FILE=''
+# Process size limit
+RLIMIT_MEM=None
+
#
########################################################################
@@ -409,7 +425,7 @@
raise 'Invalid python version', string.split(sys.version)[0]
opts, args = getopt.getopt(sys.argv[1:],
- 'hz:Z:t:i:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:')
+ 'hz:Z:t:i:H:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:')
DEBUG=0
READ_ONLY=0
@@ -436,12 +452,14 @@
try: v=string.atoi(v)
except: raise 'Invalid number of threads', v
NUMBER_OF_THREADS=v
-
elif o=='-i':
try: v=string.atoi(v)
except: raise 'Invalid value for -i option', v
sys.setcheckinterval(v)
-
+ elif o=='-H':
+ try: v = string.atoi(v)
+ except: raise 'Invalid value for -H option', v
+ RLIMIT_MEM = v
elif o=='-a': IP_ADDRESS=v
elif o=='-d':
if v=='-': v=''
@@ -562,6 +580,12 @@
from ZServer import DebugLogger
logfile=os.path.join(CLIENT_HOME, DETAILED_LOG_FILE)
DebugLogger.log=DebugLogger.DebugLogger(logfile).log
+
+ if RLIMIT_MEM:
+ import resource
+ if sys.platform =='linux2':
+ resource.setrlimit(resource.RLIMIT_AS, (RLIMIT_MEM, RLIMIT_MEM))
+ zLOG.LOG('Zope', 0, 'set memory size rlimit to %s' % RLIMIT_MEM)
# Import Zope (or Main)
exec "import "+MODULE in {}