예제 #1
0
    def __init__(self, name, loader=None, coordination=False):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        self.manager = self._get_manager()
        self.loader = loader or wsgi.Loader(CONF)
        if not rpc.initialized():
            rpc.init(CONF)
        self.app = self.loader.load_app(name)
        self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(CONF, '%s_listen_port' % name, 0)
        self.workers = getattr(CONF, '%s_workers' % name, None)
        self.use_ssl = getattr(CONF, '%s_use_ssl' % name, False)
        if self.workers is not None and self.workers < 1:
            LOG.warning(
                "Value of config option %(name)s_workers must be integer "
                "greater than 1.  Input value ignored.", {'name': name})
            # Reset workers to default
            self.workers = None
        self.server = wsgi.Server(
            CONF,
            name,
            self.app,
            host=self.host,
            port=self.port,
            use_ssl=self.use_ssl
        )
        self.coordinator = coordination
예제 #2
0
 def __init__(self,
              host,
              binary,
              topic,
              manager,
              periodic_enable=None,
              periodic_interval=None,
              periodic_fuzzy_delay=None,
              service_name=None,
              coordination=False,
              *args,
              **kwargs):
     super(Service, self).__init__()
     if not rpc.initialized():
         rpc.init(CONF)
     self.host = host
     self.binary = binary
     self.topic = topic
     self.manager_class_name = manager
     manager_class = importutils.import_class(self.manager_class_name)
     self.manager = manager_class(host=self.host,
                                  service_name=service_name,
                                  *args,
                                  **kwargs)
     self.periodic_enable = periodic_enable
     self.periodic_interval = periodic_interval
     self.periodic_fuzzy_delay = periodic_fuzzy_delay
     self.saved_args, self.saved_kwargs = args, kwargs
     self.timers = []
     self.coordinator = coordination