Commit 39369169 authored by Levin Zimmermann's avatar Levin Zimmermann

ERP5/zopewsgi: Add option to set soft limit of open file descriptors to hard limit

The default soft limit of open file descriptors is usually set to 1024
in order to avoid breaking old software which still uses select. In many
projects we may need a higher limit: particularly in Wendelin based
projects we easily reach this limit. Before this patch it was therefore
necessary to either patch ERP5 in the project specific SR or to manually
increase the limit of the zope processes (or the parent supervisor) with
a tool like prlimit [1]. With this patch it becomes possible to increase the
soft limit to the hard limit with a command line argument of the zopewsgi bin.
This simplifies setting the soft limit for any Wendelin project.

[1] https://man7.org/linux/man-pages/man1/prlimit.1.html

/reviewed-by @vpelletier, @jerome
/reviewed-on !1827
parent 56718dcf
Pipeline #30645 failed with stage
...@@ -5,6 +5,7 @@ from io import BytesIO ...@@ -5,6 +5,7 @@ from io import BytesIO
import logging import logging
import os import os
import posixpath import posixpath
import resource
import signal import signal
import socket import socket
import sys import sys
...@@ -184,6 +185,10 @@ def runwsgi(): ...@@ -184,6 +185,10 @@ def runwsgi():
'instead of being read completely into memory.', 'instead of being read completely into memory.',
type=type_registry.get('byte-size'), type=type_registry.get('byte-size'),
default=type_registry.get('byte-size')("10MB")) default=type_registry.get('byte-size')("10MB"))
parser.add_argument(
'--nofile',
help='Set soft limit of file descriptors erp5 can open to hard limit',
action="store_true")
args = parser.parse_args() args = parser.parse_args()
# Configure logging previously handled by ZConfig/ZServer # Configure logging previously handled by ZConfig/ZServer
...@@ -258,6 +263,11 @@ def runwsgi(): ...@@ -258,6 +263,11 @@ def runwsgi():
interval=args.timerserver_interval, interval=args.timerserver_interval,
) )
if args.nofile:
cur_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
new_limit = (cur_limit[1], cur_limit[1])
resource.setrlimit(resource.RLIMIT_NOFILE, new_limit)
ip, port = splitport(args.address) ip, port = splitport(args.address)
port = int(port) port = int(port)
createServer( createServer(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment