diff --git a/circus/arbiter.py b/circus/arbiter.py index d8fc10e52..904d560c0 100644 --- a/circus/arbiter.py +++ b/circus/arbiter.py @@ -1,6 +1,7 @@ import errno import logging import os +import gc from circus.fixed_threading import Thread, get_ident import sys from time import sleep @@ -67,6 +68,9 @@ class Arbiter(object): to /dev/null. (default: False) - **debug** -- if True, adds a lot of debug info in the stdout (default: False) + - **debug_gc** -- if True, does gc.set_debug(gc.DEBUG_LEAK) (default: + False) + to circusd to analyze problems (default: False) - **proc_name** -- the arbiter process name - **fqdn_prefix** -- a prefix for the unique identifier of the circus instance on the cluster. @@ -79,7 +83,7 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, multicast_endpoint=None, plugins=None, sockets=None, warmup_delay=0, httpd=False, httpd_host='localhost', httpd_port=8080, - httpd_close_outputs=False, debug=False, + httpd_close_outputs=False, debug=False, debug_gc=False, ssh_server=None, proc_name='circusd', pidfile=None, loglevel=None, logoutput=None, fqdn_prefix=None, umask=None, endpoint_owner=None): @@ -131,6 +135,10 @@ def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=1.0, else: self.stdout_stream = self.stderr_stream = None + self.debug_gc = debug_gc + if debug_gc: + gc.set_debug(gc.DEBUG_LEAK) + # initializing circusd-stats as a watcher when configured self.statsd = statsd self.stats_endpoint = stats_endpoint @@ -422,6 +430,7 @@ def load_from_config(cls, config_file, loop=None): httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080), debug=cfg.get('debug', False), + debug_gc=cfg.get('debug_gc', False), ssh_server=cfg.get('ssh_server', None), pidfile=cfg.get('pidfile', None), loglevel=cfg.get('loglevel', None), diff --git a/circus/config.py b/circus/config.py index 063707a92..bc9285ce0 100644 --- a/circus/config.py +++ b/circus/config.py @@ -165,6 +165,7 @@ def _upper(items): config['httpd_host'] = dget('circus', 'httpd_host', 'localhost', str) config['httpd_port'] = dget('circus', 'httpd_port', 8080, int) config['debug'] = dget('circus', 'debug', False, bool) + config['debug_gc'] = dget('circus', 'debug_gc', False, bool) config['pidfile'] = dget('circus', 'pidfile') config['loglevel'] = dget('circus', 'loglevel') config['logoutput'] = dget('circus', 'logoutput') diff --git a/docs/source/for-ops/configuration.rst b/docs/source/for-ops/configuration.rst index 3db9a1997..382b4027c 100644 --- a/docs/source/for-ops/configuration.rst +++ b/docs/source/for-ops/configuration.rst @@ -98,6 +98,10 @@ circus - single section **debug** If set to True, all Circus stout/stderr daemons are redirected to circusd stdout/stderr (default: False) + **debug_gc** + If set to True, circusd outputs additional log info from the garbage + collector. This can be useful in tracking down memory leaks. + (default: False) **pidfile** The file that must be used to keep the daemon pid. **umask**