From 96670784f916aebc244fea88fb24e39fa9edd757 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 10 May 2016 14:44:52 -0400 Subject: [PATCH] Automatically increase limits Knowing ahead of time that confluent is the sort of app that, despite best efforts, is filehandle heavy, auto-attempt to raise soft to be equal to hard limit. A sufficiently large cluster (i.e. more than 2000 nodes) would still need to have limit adjusted at system level for now. --- confluent_server/confluent/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 2eaee4da..6160f9e7 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -164,7 +164,19 @@ def _initsecurity(config): configmanager.ConfigManager.wait_for_sync() +def setlimits(): + try: + import resource + currlimit = resource.getrlimit(resource.RLIMIT_NOFILE) + if currlimit[0] < currlimit[1]: + resource.setrlimit( + resource.RLIMIT_NOFILE, (currlimit[1], currlimit[1])) + except Exception: + pass + + def run(): + setlimits() signal.signal(signal.SIGUSR1, dumptrace) if havefcntl: _checkpidfile()