monasca-log-api/monasca_log_api/app/main.py
Tomasz Trębski 138ac174c4 Allow to specify CLI arguments
Passing any CLI arguments to log-api is not possible
for the case where it runs under gunicorn server.
Gunicorn's argument parsing processes clashes with oslo's.
Effectivelly that means that either of them cannot understand
the arguments of another. However log-api is capable of being launched
under, for example, apache_mod-wsgi.
That permits passing oslo CLI arguments.

Added simple method that detect the executable that was used to run
log-api. If that is not gunicorn, CLI opts will be enabled.
Otherwise log-api will print out warning and proceed as it was.

Extra:
* reworked to use fixtures

Change-Id: I6b2fc386aeb823ab735270ffc1d3f7e15985830f
2017-07-27 07:34:02 +02:00

49 lines
1.3 KiB
Python

# Copyright 2017 FUJITSU LIMITED
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Allows to run monasca-log-api from within local [dev] environment.
Primarily used for development.
"""
import sys
from paste import deploy
from paste import httpserver
from monasca_log_api import version
def get_wsgi_app():
config_dir = 'etc/monasca'
return deploy.loadapp(
'config:%s/log-api-paste.ini' % config_dir,
relative_to='./',
name='main'
)
def main():
wsgi_app = get_wsgi_app()
server_version = 'log-api/%s' % version.version_str
server = httpserver.serve(application=wsgi_app, host='127.0.0.1',
port=5607, server_version=server_version)
return server
if __name__ == '__main__':
sys.exit(main())