diff --git a/setup.py b/setup.py index 74f6c3e26b1e36f1b66f2c2a417ab203587a5322..dac7501f6c7458ed7414d8d941895b2422f93d49 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ setup(name=name, 'netaddr>=0.7.5', # to play safely with IPv6 prefixes 'netifaces', # to fetch information about network devices 'setuptools', # namespaces - 'supervisor', # slapgrid uses supervisor to manage processes + 'supervisor>=3.3.0', # slapgrid uses supervisor to manage processes 'psutil>=2.0.0', 'xml_marshaller>=0.9.3', # to unmarshall/marshall python objects to/from # XML @@ -75,6 +75,7 @@ setup(name=name, 'cachecontrol', 'lockfile', 'uritemplate', # used by hateoas navigator + 'resource', 'subprocess32; python_version<"3"' ] + additional_install_requires, extras_require=extras_require, diff --git a/slapos/grid/svcbackend.py b/slapos/grid/svcbackend.py index 668680cee003dd61d2072f8976b4733a32b63a11..e7a73c6bfb4f5141724d4a5025ba4dd7e59253a5 100644 --- a/slapos/grid/svcbackend.py +++ b/slapos/grid/svcbackend.py @@ -31,6 +31,7 @@ import os import pkg_resources import socket as socketlib +import resource import subprocess import stat import sys @@ -175,7 +176,10 @@ def launchSupervisord(instance_root, logger, supervisord_argument_list = ['-c', configuration_file] if supervisord_additional_argument_list is not None: supervisord_argument_list.extend(supervisord_additional_argument_list) - + def preexec_fn(): + cur_limit = resource.getrlimit(resource.RLIMIT_NOFILE) + new_limit = (cur_limit[1], cur_limit[1]) # set the soft limit to the hard limit + resource.setrlimit(resource.RLIMIT_NOFILE, new_limit) logger.info("Launching supervisord with clean environment.") # Extract python binary to prevent shebang size limit invocation_list = [sys.executable, '-c'] @@ -188,7 +192,8 @@ def launchSupervisord(instance_root, logger, env={}, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - logger=logger) + logger=logger, + preexec_fn=preexec_fn) result = supervisord_popen.communicate()[0] if supervisord_popen.returncode: