Example #1
0
    def __init__(self, name, loader=None):
        """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()
        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,
                               processutils.get_worker_count())
        if self.workers < 1:
            LOG.warn(_("Value of config option %(name)s_workers must be "
                       "integer greater than 1.  Input value ignored.") %
                     {'name': name})
            # Reset workers to default
            self.workers = processutils.get_worker_count()
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port)
Example #2
0
    def __init__(self, name, loader=None):
        """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()
        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,
                               processutils.get_worker_count())
        setup_profiler(name, self.host)

        if self.workers < 1:
            LOG.warn(
                _("Value of config option %(name)s_workers must be "
                  "integer greater than 1.  Input value ignored.") %
                {'name': name})
            # Reset workers to default
            self.workers = processutils.get_worker_count()
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port)
Example #3
0
    def __init__(self, name, loader=None):
        """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()
        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) or
                        processutils.get_worker_count())
        if self.workers and self.workers < 1:
            worker_name = '%s_workers' % name
            msg = (_("%(worker_name)s value of %(workers)d is invalid, "
                     "must be greater than 0.") %
                   {'worker_name': worker_name,
                    'workers': self.workers})
            raise exception.InvalidInput(msg)
        setup_profiler(name, self.host)

        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port)
Example #4
0
    def __init__(self, name, loader=None):
        """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()
        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)
                        or processutils.get_worker_count())
        if self.workers and self.workers < 1:
            worker_name = '%s_workers' % name
            msg = (_("%(worker_name)s value of %(workers)d is invalid, "
                     "must be greater than 0.") % {
                         'worker_name': worker_name,
                         'workers': self.workers
                     })
            raise exception.InvalidInput(msg)
        setup_profiler(name, self.host)

        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port)
Example #5
0
 def test_workers_set_zero_user_setting(self):
     self.override_config('osapi_volume_workers', 0)
     test_service = service.WSGIService("osapi_volume")
     # If a value less than 1 is used, defaults to number of procs available
     self.assertEqual(test_service.workers, processutils.get_worker_count())
Example #6
0
 def test_workers_set_default(self):
     test_service = service.WSGIService("osapi_volume")
     self.assertEqual(test_service.workers, processutils.get_worker_count())
Example #7
0
 def test_workers_set_zero_user_setting(self):
     CONF.set_override('osapi_volume_workers', 0)
     test_service = service.WSGIService("osapi_volume")
     # If a value less than 1 is used, defaults to number of procs available
     self.assertEqual(test_service.workers, processutils.get_worker_count())
Example #8
0
 def test_workers_set_default(self):
     test_service = service.WSGIService("osapi_volume")
     self.assertEqual(test_service.workers, processutils.get_worker_count())