Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Increase daemon's file handles to 8192
Browse files Browse the repository at this point in the history
  • Loading branch information
thieman committed Mar 14, 2016
1 parent 17e07e9 commit a30f8b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dusty/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 10 additions & 0 deletions dusty/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import socket
import threading
import resource
# requests refused to play nicely with pyinstaller
import httplib

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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']:
Expand Down

0 comments on commit a30f8b5

Please sign in to comment.