diff --git a/aodh/api/app.py b/aodh/api/app.py index 025bf2ae..c88fc6ba 100644 --- a/aodh/api/app.py +++ b/aodh/api/app.py @@ -27,7 +27,6 @@ from aodh.api import hooks from aodh.api import middleware from aodh.i18n import _ from aodh.i18n import _LW -from aodh import service from aodh import storage @@ -41,6 +40,7 @@ OPTS = [ help="Configuration file for WSGI definition of API." ), cfg.IntOpt('api_workers', default=1, + min=1, help='Number of workers for aodh API server.'), ] @@ -74,7 +74,7 @@ def setup_app(pecan_config=None): # NOTE(sileht): pecan debug won't work in multi-process environment pecan_debug = CONF.api.pecan_debug - if service.get_workers('api') != 1 and pecan_debug: + if cfg.CONF.api_workers != 1 and pecan_debug: pecan_debug = False LOG.warning(_LW('pecan_debug cannot be enabled, if workers is > 1, ' 'the value is overrided with False')) @@ -123,9 +123,8 @@ def build_server(): LOG.info(_("serving on http://%(host)s:%(port)s") % ( {'host': host, 'port': port})) - workers = service.get_workers('api') serving.run_simple(cfg.CONF.api.host, cfg.CONF.api.port, - app, processes=workers) + app, processes=cfg.CONF.api_workers) def _app(): diff --git a/aodh/service.py b/aodh/service.py index bb091d45..c53192e0 100644 --- a/aodh/service.py +++ b/aodh/service.py @@ -32,7 +32,6 @@ from aodh.i18n import _ from aodh import messaging from aodh import rpc from aodh import storage -from aodh import utils OPTS = [ @@ -105,21 +104,6 @@ cfg.CONF.register_cli_opts(CLI_OPTS, group="service_credentials") LOG = log.getLogger(__name__) -class WorkerException(Exception): - """Exception for errors relating to service workers.""" - - -def get_workers(name): - workers = (cfg.CONF.get('%s_workers' % name) or - utils.cpu_count()) - if workers and workers < 1: - msg = (_("%(worker_name)s value of %(workers)s is invalid, " - "must be greater than 0") % - {'worker_name': '%s_workers' % name, 'workers': str(workers)}) - raise WorkerException(msg) - return workers - - def prepare_service(argv=None): oslo_i18n.enable_lazy() log.register_options(cfg.CONF) diff --git a/requirements.txt b/requirements.txt index 5132c0fc..b5a26a3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ keystonemiddleware>=1.5.0 lxml>=2.3 oslo.context>=0.2.0 # Apache-2.0 oslo.db>=1.12.0 # Apache-2.0 -oslo.config>=1.11.0 # Apache-2.0 +oslo.config>=1.15.0 # Apache-2.0 oslo.i18n>=1.5.0 # Apache-2.0 oslo.log>=1.2.0 # Apache-2.0 oslo.policy>=0.5.0 # Apache-2.0