Commit 08be8e99 authored by Levin Zimmermann's avatar Levin Zimmermann

Always set soft fds limit to hard fds limit

This patch is specifically for the WWM/wind project. It unconditionally
sets the soft limit of open file descriptors to the hard limit. It is
'unconditionally' in two meanings:

1. Always set it and don't depend on instance configuration (via
   'instance.json). We certainly want this in the WWM/wind instance and
   adding the option to SlapOS would lead to a lot of copy-pasted SlapOS
   instance files in the WWM project, which are noisy, difficult to
   maintain and tedious to create.

2. Always set it and don't depend on the used server (Medusa or WSGI).
   In the upstream patches nexedi/erp5@39369169
   and nexedi/erp5@c42c1d38
   the option is only made available when using WSGI. But in our production
   instance we may want to switch back to ZServer/Medusa, which is why
   we need an ERP5 which supports the option independent from the used
   server.
parent a6f6c48f
......@@ -165,10 +165,6 @@ def runwsgi():
parser.add_argument('address', help='<ip>:<port>')
parser.add_argument('zope_conf', help='path to zope.conf')
parser.add_argument('--timerserver-interval', help='Interval for timerserver', type=float)
parser.add_argument(
'--with-max-rlimit-nofile',
help='Set soft limit of file descriptors erp5 can open to hard limit',
action="store_true")
args = parser.parse_args()
startup = os.path.dirname(Zope2.Startup.__file__)
......@@ -191,10 +187,9 @@ def runwsgi():
interval=args.timerserver_interval,
)
if args.with_max_rlimit_nofile:
cur_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
new_limit = (cur_limit[1], cur_limit[1])
resource.setrlimit(resource.RLIMIT_NOFILE, new_limit)
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)
port = int(port)
......
......@@ -32,7 +32,7 @@
"""
from __future__ import absolute_import
from App.config import getConfiguration
from .patches import python, globalrequest, Pandas
from .patches import python, globalrequest, Pandas, Zope2
import six
if six.PY2:
from .patches import pylint
......
##############################################################################
#
# Copyright (c) 2023 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import resource
import Zope2.Startup.run
_orig_run = Zope2.Startup.run.run
def run(*args, **kwargs):
cur_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
new_limit = (cur_limit[1], cur_limit[1])
resource.setrlimit(resource.RLIMIT_NOFILE, new_limit)
return _orig_run(*args, **kwargs)
Zope2.Startup.run.run = run
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