18 from oslo_config
import cfg
19 from oslo_log
import log
20 from oslo_policy
import opts
as policy_opts
22 from monasca_api
import conf
23 from monasca_api
import version
26 LOG = log.getLogger(__name__)
29 _GUNICORN_MARKER =
'gunicorn'
33 """Loads application configuration.
35 Loads entire application configuration just once.
40 LOG.debug(
'Configuration has been already loaded')
44 log.register_options(CONF)
46 argv = (argv
if argv
is not None else sys.argv[1:])
52 version=version.version_str,
54 description=
'RESTful API for alarming in the cloud')
57 product_name=
'monasca-api',
58 version=version.version_str)
60 policy_opts.set_defaults(CONF)
66 """Get the possible configuration files accepted by oslo.config
68 This also includes the deprecated ones
71 conf_files = cfg.find_config_files(project=
'monasca', prog=
'monasca-api')
73 if len(conf_files) == 0:
74 for prog_name
in [
'api',
'api-config']:
75 old_conf_files = cfg.find_config_files(project=
'monasca', prog=prog_name)
76 if len(old_conf_files) > 0:
77 LOG.warning(
'Found deprecated old location "{}" '
78 'of main configuration file'.format(old_conf_files))
79 conf_files += old_conf_files
84 """Evaluates if api runs under gunicorn."""
85 content = filter(
lambda x: x != sys.executable
and _GUNICORN_MARKER
in x,
87 return len(list(content)
if not isinstance(content, list)
else content) > 0