Skip to content

Commit

Permalink
Merge pull request #2792 from natefoo/uwsgi-fork-raven
Browse files Browse the repository at this point in the history
[16.07] Do not instantiate the raven (sentry) client or tool conf watchdog threads until uWSGI postfork
  • Loading branch information
dannon committed Aug 16, 2016
2 parents 40f8589 + c431d8c commit a13117f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
12 changes: 8 additions & 4 deletions lib/galaxy/app.py
Expand Up @@ -149,11 +149,15 @@ def __init__( self, **kwargs ):
)
self.heartbeat.daemon = True
register_postfork_function(self.heartbeat.start)
self.sentry_client = None
if self.config.sentry_dsn:
import raven
self.sentry_client = raven.Client(self.config.sentry_dsn)
else:
self.sentry_client = None

def postfork_sentry_client():
import raven
self.sentry_client = raven.Client(self.config.sentry_dsn)

register_postfork_function(postfork_sentry_client)

# Transfer manager client
if self.config.get_bool( 'enable_beta_job_managers', False ):
from galaxy.jobs import transfer_manager
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/config.py
Expand Up @@ -23,6 +23,7 @@
from galaxy.util import listify
from galaxy.util import string_as_bool
from galaxy.util.dbkeys import GenomeBuilds
from galaxy.util.postfork import register_postfork_function
from galaxy.web.formatting import expand_pretty_datetime_format
from .version import VERSION_MAJOR

Expand Down Expand Up @@ -785,7 +786,7 @@ def configure_logging( config ):
from raven.handlers.logging import SentryHandler
sentry_handler = SentryHandler( config.sentry_dsn )
sentry_handler.setLevel( logging.WARN )
root.addHandler( sentry_handler )
register_postfork_function(root.addHandler, sentry_handler)


class ConfiguresGalaxyMixin:
Expand Down
4 changes: 3 additions & 1 deletion lib/galaxy/tools/toolbox/watcher.py
Expand Up @@ -14,6 +14,8 @@
PollingObserver = None
can_watch = False

from galaxy.util.postfork import register_postfork_function

log = logging.getLogger( __name__ )


Expand Down Expand Up @@ -151,7 +153,7 @@ def __init__(self, toolbox, observer_class):
self.start()

def start(self):
self.observer.start()
register_postfork_function(self.observer.start)

def shutdown(self):
self.observer.stop()
Expand Down
9 changes: 8 additions & 1 deletion lib/galaxy/web/framework/middleware/sentry.py
Expand Up @@ -12,6 +12,8 @@
except:
Client = None

from galaxy.util.postfork import register_postfork_function


RAVEN_IMPORT_MESSAGE = ('The Python raven package is required to use this '
'feature, please install it')
Expand All @@ -25,7 +27,12 @@ class Sentry(object):
def __init__(self, application, dsn):
assert Client is not None, RAVEN_IMPORT_MESSAGE
self.application = application
self.client = Client( dsn )
self.client = None

def postfork_sentry_client():
self.client = Client( dsn )

register_postfork_function(postfork_sentry_client)

def __call__(self, environ, start_response):
try:
Expand Down

0 comments on commit a13117f

Please sign in to comment.