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

Commit

Permalink
Merge pull request #660 from gamechanger/tnt-file-handles
Browse files Browse the repository at this point in the history
Increase daemon's file handles to 8192
  • Loading branch information
thieman committed Mar 14, 2016
2 parents 17e07e9 + aa22fee commit eee6cb3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Added a custom 502 page for apps which use host forwarding. This lets you see the status and logs of your container while you're waiting for its HTTP service to come online
* **Misc**
* Implemented a [networking fix](https://github.com/docker/machine/pull/3112) the Dusty team implemented in Docker Machine within Dusty
* The daemon now raises its open file handle limit to 8192, which should prevent some OSErrors during parallelized Git operations

## 0.7.0 (February 18, 2016)

Expand Down
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 eee6cb3

Please sign in to comment.