diff --git a/dusty/constants.py b/dusty/constants.py index a743d4ff..32c438c8 100644 --- a/dusty/constants.py +++ b/dusty/constants.py @@ -30,6 +30,8 @@ DAEMON_HTTP_BIND_IP = '127.0.0.1' DAEMON_HTTP_BIND_PORT = 60912 +FILE_HANDLE_LIMIT = 8192 + FIRST_RUN_FILE_PATH = '/.dusty_first_time_started' CONTAINER_LOG_PATH = "/var/log" diff --git a/dusty/daemon.py b/dusty/daemon.py index c627a412..c4674b35 100644 --- a/dusty/daemon.py +++ b/dusty/daemon.py @@ -12,6 +12,7 @@ import logging import socket import threading +import resource # requests refused to play nicely with pyinstaller import httplib @@ -64,6 +65,14 @@ def close_client_connection(terminator=SOCKET_TERMINATOR): close_socket_logger() connection.close() +def _increase_file_handle_limit(): + """Raise the open file handles permitted by the Dusty daemon process + and its child processes. The number we choose here needs to be within + the OS X default kernel hard limit, which is 10240.""" + logging.info('Increasing file handle limit to {}'.format(constants.FILE_HANDLE_LIMIT)) + resource.setrlimit(resource.RLIMIT_NOFILE, + (constants.FILE_HANDLE_LIMIT, resource.RLIM_INFINITY)) + def shut_down_http_server(): logging.info('Daemon is shutting down HTTP server') try: @@ -137,6 +146,7 @@ def _listen_on_socket(socket_path, suppress_warnings): def main(): args = docopt(__doc__) configure_logging() + _increase_file_handle_limit() init_yaml_constructor() preflight_check() if args['--preflight-only']: