Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 47 lines (34 sloc) 1.489 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
"""
sentry.services.http
~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from django.core.management import call_command
from sentry.services.base import Service


class SentryHTTPServer(Service):
    name = 'http'

    def __init__(self, host=None, port=None, debug=False, workers=None):
        from sentry.conf import settings

        self.host = host or settings.WEB_HOST
        self.port = port or settings.WEB_PORT
        self.workers = workers

        # import cProfile, os

        # def post_fork(server, worker):
        # orig_init_process_ = worker.init_process

        # def profiling_init_process(self):
        # orig_init_process = orig_init_process_
        # ofile = '/tmp/.profile%s' % (os.getpid(),)
        # print 'Profiling worker %s, output file: %s' % (worker, ofile)
        # cProfile.runctx('orig_init_process()', globals(), locals(), ofile)
        # worker.init_process = profiling_init_process.__get__(worker)

        options = (settings.WEB_OPTIONS or {}).copy()
        options['bind'] = '%s:%s' % (self.host, self.port)
        options['debug'] = debug
        options.setdefault('daemon', False)
        options.setdefault('timeout', 30)
        if workers:
            options['workers'] = workers

        self.options = options

    def run(self):
        call_command('run_gunicorn', **self.options)
Something went wrong with that request. Please try again.