Commit 070e6b9d authored by Levin Zimmermann's avatar Levin Zimmermann

software/erp5: Add nofile option

erp5@d8b5b910 added the functionality to ERP5 to
set its soft limit of allowed open file descriptors to the system wide hard limit.
This parameter is useful for Wendelin based instances where the 1024
limit is easily reached.

With this patch, this parameter can also be set via SlapOS, which
simplifies usage of the Wendelin SR.
parent 351fb379
......@@ -103,6 +103,11 @@
"null"
]
},
"nofile": {
"description": "Set open file descriptors soft limit to hard limit",
"default": false,
"type": "boolean"
},
"family-override": {
"description": "Family-wide options, possibly overriding global options",
"default": {},
......
......@@ -32,6 +32,7 @@ import glob
import http.client
import json
import os
import resource
import shutil
import socket
import sqlite3
......@@ -1100,3 +1101,36 @@ class TestNEO(ZopeSkinsMixin, CrontabMixin, ERP5InstanceTestCase):
'var',
'log',
f))
class TestNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test setting the nofile parameter sets the open fd soft limit to the hard limit.
"""
__partition_reference__ = 'nofile'
@classmethod
def getInstanceParameterDict(cls):
return {'_': json.dumps({'nofile': True})}
def test_nofile(self):
with self.slap.instance_supervisor_rpc as supervisor:
all_process_info = supervisor.getAllProcessInfo()
_, current_hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
process_info, = (p for p in all_process_info if p['name'].startswith('zope-'))
self.assertEqual(
resource.prlimit(process_info['pid'], resource.RLIMIT_NOFILE),
(current_hard_limit, current_hard_limit))
class TestUnsetNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test not setting the nofile parameter doesn't change the soft limit of erp5
"""
__partition_reference__ = 'unsetnofile'
def test_unset_nofile(self):
with self.slap.instance_supervisor_rpc as supervisor:
all_process_info = supervisor.getAllProcessInfo()
limit = resource.getrlimit(resource.RLIMIT_NOFILE)
process_info, = (p for p in all_process_info if p['name'].startswith('zope-'))
self.assertEqual(
resource.prlimit(process_info['pid'], resource.RLIMIT_NOFILE), limit)
......@@ -74,7 +74,7 @@ md5sum = 3f7b28085ceff321a3cb785db60f7c3e
[template-erp5]
filename = instance-erp5.cfg.in
md5sum = 098e1d02159aeca9b36f2a0726b7b230
md5sum = 3a76b7bdb9066e61a376010e51d41d6d
[template-zeo]
filename = instance-zeo.cfg.in
......@@ -86,7 +86,7 @@ md5sum = 0ac4b74436f554cd677f19275d18d880
[template-zope]
filename = instance-zope.cfg.in
md5sum = 9e6440425167a506bd473a3697eaa9e6
md5sum = e8e5e0bbfb4d4ceb98ef1eac35ec5178
[template-balancer]
filename = instance-balancer.cfg.in
......
......@@ -311,6 +311,7 @@ config-longrequest-logger-interval = {{ dumps(zope_parameter_dict.get('longreque
config-longrequest-logger-timeout = {{ dumps(zope_parameter_dict.get('longrequest-logger-timeout', 1)) }}
config-large-file-threshold = {{ dumps(zope_parameter_dict.get('large-file-threshold', "10MB")) }}
config-port-base = {{ dumps(zope_parameter_dict.get('port-base', 2200)) }}
config-nofile = {{ dumps(slapparameter_dict.get('nofile', false)) }}
{# BBB: zope_parameter_dict used to contain 'webdav', so fallback to it -#}
config-webdav = {{ dumps(current_zope_family_override_dict.get('webdav', zope_parameter_dict.get('webdav', False))) }}
config-publisher-timeout = {{ dumps(current_zope_family_override_dict.get('publisher-timeout', global_publisher_timeout)) }}
......
{% from "instance_zodb_base" import zodb_dict with context %}
{% set webdav = slapparameter_dict['webdav'] -%}
{% set nofile = slapparameter_dict['nofile'] -%}
{% set thread_amount = slapparameter_dict['thread-amount'] %}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set ports = itertools.count(slapparameter_dict['port-base']) -%}
......@@ -346,6 +347,7 @@ wrapped-command-line =
--access-log-file={{ '${' ~ conf_parameter_name ~ ':z2-log}' }}
{% if longrequest_logger_interval > 0 %} --long-request-log-file={{ '${' ~ conf_parameter_name ~ ':longrequest-logger-file}' }} {% endif %}
{% if webdav %}-w{% endif %}
{% if nofile %}--nofile{% endif %}
{{ ipv4 }}:${:port}
{% if timerserver_interval %}--timerserver-interval={{ timerserver_interval }}{% endif %}
'${:configuration-file}'
......
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