def __init__(self, action='start', options={}, reactor=reactor, threadpool=None): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.threadpool = threadpool or ThreadPool(name="Hendrix Web Service") self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: if hasattr(self.options['wsgi'], '__call__'): # If it has a __call__, we assume that it is the application # object itself. self.application = self.options['wsgi'] try: self.options['wsgi'] = "%s.%s" % ( self.application.__module__, self.application.__name__) except AttributeError: self.options['wsgi'] = self.application.__class__.__name__ else: # Otherwise, we'll try to discern an application in the belief # that this is a dot path. wsgi_dot_path = self.options['wsgi'] # will raise AttributeError if we can't import it. self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] settings = import_string('django.conf.settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: django = importlib.import_module('django') if django.VERSION[:2] >= (1, 7): django.setup() wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = [] self._lock = DeferredLock()
def __init__(self, action='start', options={}, reactor=reactor, threadpool=None): self.action = action self.options = hx_options() self.options.update(options) self.services = [] self.resources = [] self.reactor = reactor self.threadpool = threadpool or ThreadPool(name="Hendrix Web Service") self.use_settings = True # because running the management command overrides self.options['wsgi'] if self.options['wsgi']: if hasattr(self.options['wsgi'], '__call__'): # If it has a __call__, we assume that it is the application # object itself. self.application = self.options['wsgi'] try: self.options['wsgi'] = "%s.%s" % ( self.application.__module__, self.application.__name__ ) except AttributeError: self.options['wsgi'] = self.application.__class__.__name__ else: # Otherwise, we'll try to discern an application in the belief # that this is a dot path. wsgi_dot_path = self.options['wsgi'] # will raise AttributeError if we can't import it. self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.use_settings = False else: os.environ['DJANGO_SETTINGS_MODULE'] = self.options['settings'] settings = import_string('django.conf.settings') self.services = get_additional_services(settings) self.resources = get_additional_resources(settings) self.options = HendrixDeploy.getConf(settings, self.options) if self.use_settings: django = importlib.import_module('django') if django.VERSION[:2] >= (1, 7): django.setup() wsgi_dot_path = getattr(settings, 'WSGI_APPLICATION', None) self.application = HendrixDeploy.importWSGI(wsgi_dot_path) self.is_secure = self.options['key'] and self.options['cert'] self.servers = [] self._lock = DeferredLock()