From 44c3cdef5c31bdcdc8e4961ec9d8ce1647aa8c09 Mon Sep 17 00:00:00 2001 From: "wu.chunyang" Date: Wed, 24 Aug 2022 17:17:42 +0800 Subject: Rename app.wsgi to app_wsgi.py 1. app.wsgi is a python script and should be end with py extension. 2. Generate trove-wsgi script which is needed by kolla to support https and ipv6. 3. Ignore build directory in git 4. update docs Change-Id: Ibbd6ecb8db25aa3a443d3f526f4cf6d418eb26f3 --- .gitignore | 5 ++++ devstack/files/apache-trove-api.template | 2 +- devstack/plugin.sh | 2 +- doc/source/install/apache-mod-wsgi.rst | 2 +- etc/apache2/trove | 2 +- setup.cfg | 2 ++ tox.ini | 2 +- trove/cmd/api_wsgi.py | 42 ++++++++++++++++++++++++++++++++ trove/cmd/app.wsgi | 41 ------------------------------- 9 files changed, 54 insertions(+), 46 deletions(-) create mode 100644 trove/cmd/api_wsgi.py delete mode 100644 trove/cmd/app.wsgi diff --git a/.gitignore b/.gitignore index 35949d15..38857d78 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,11 @@ trove.iml # Files generated by Visual Studio Code .vscode/ +# Files generated by setup.py +*.egg-info +build +.eggs + # Sphinx doc/build/* doc/source/api/* diff --git a/devstack/files/apache-trove-api.template b/devstack/files/apache-trove-api.template index 06c88b26..767f18cf 100644 --- a/devstack/files/apache-trove-api.template +++ b/devstack/files/apache-trove-api.template @@ -21,7 +21,7 @@ Listen %TROVE_SERVICE_PORT% WSGIDaemonProcess trove-api user=%USER% processes=%APIWORKERS% threads=1 display-name=%{GROUP} - WSGIScriptAlias / %TROVE_WSGI_DIR%/app.wsgi + WSGIScriptAlias / %TROVE_WSGI_DIR%/app_wsgi.py WSGIApplicationGroup %{GLOBAL} WSGIProcessGroup trove-api WSGIPassAuthorization On diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 2b34158e..3ef04fbb 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -169,7 +169,7 @@ function config_trove_apache_wsgi { local trove_apache_conf sudo mkdir -p ${TROVE_WSGI_DIR} - sudo cp $TROVE_DIR/trove/cmd/app.wsgi $TROVE_WSGI_DIR/app.wsgi + sudo cp $TROVE_DIR/trove/cmd/app_wsgi.py $TROVE_WSGI_DIR/app.wsgi trove_apache_conf=$(apache_site_config_for trove-api) sudo cp $TROVE_DEVSTACK_FILES/apache-trove-api.template ${trove_apache_conf} sudo sed -e " diff --git a/doc/source/install/apache-mod-wsgi.rst b/doc/source/install/apache-mod-wsgi.rst index 61968662..7b4d855d 100644 --- a/doc/source/install/apache-mod-wsgi.rst +++ b/doc/source/install/apache-mod-wsgi.rst @@ -36,7 +36,7 @@ Installing API behind mod_wsgi * Modify the ``WSGIDaemonProcess`` directive to set the ``user`` and ``group`` values to appropriate user on your server. * Modify the ``WSGIScriptAlias`` directive to point to the - trove/api/app.wsgi script. + trove/api/app_wsgi.py script. * Modify the ``Directory`` directive to set the path to the Trove API code. * Modify the ``ErrorLog and CustomLog`` to redirect the logs to the right diff --git a/etc/apache2/trove b/etc/apache2/trove index 1ed82c26..d8257423 100644 --- a/etc/apache2/trove +++ b/etc/apache2/trove @@ -19,7 +19,7 @@ Listen 8779 WSGIDaemonProcess trove-api user=stack group=stack processes=2 threads=2 display-name=%{GROUP} - WSGIScriptAlias / /opt/stack/trove/trove/cmd/app.wsgi + WSGIScriptAlias / /opt/stack/trove/trove/cmd/app_wsgi.py WSGIProcessGroup trove-api ErrorLog /var/log/httpd/trove_error.log diff --git a/setup.cfg b/setup.cfg index 393898ba..340ff3ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,8 @@ packages = trove [entry_points] +wsgi_scripts = + trove-wsgi = trove.cmd.api_wsgi:wsgimain console_scripts = trove-api = trove.cmd.api:main trove-taskmanager = trove.cmd.taskmanager:main diff --git a/tox.ini b/tox.ini index c35a01df..4a24d45f 100644 --- a/tox.ini +++ b/tox.ini @@ -65,7 +65,7 @@ builtins = _ # add *.yaml for playbooks/trove-devstack-base.yaml, as it will be matched by # trove-* in the "filename" configuration. exclude=.venv,.tox,.git,dist,doc,*egg,tools,etc,build,*.po,*.pot,integration,releasenotes,*.yaml -filename=*.py,trove-*,app.wsgi +filename=*.py,trove-* [hacking] import_exceptions = trove.common.i18n diff --git a/trove/cmd/api_wsgi.py b/trove/cmd/api_wsgi.py new file mode 100644 index 00000000..78eadd5b --- /dev/null +++ b/trove/cmd/api_wsgi.py @@ -0,0 +1,42 @@ +# Copyright 2017 Amrith Kumar. +# All Rights Reserved. +# +# 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. +""" +Used for deploying Trove API through mod-wsgi +""" + +from oslo_log import log as logging +from trove.cmd.common import with_initialize +from trove.common import pastedeploy +from trove.common import profile + +LOG = logging.getLogger('trove.cmd.app') + + +@with_initialize +def wsgimain(CONF): + from trove.common import cfg + from trove.common import notification + from trove.instance import models as inst_models + + notification.DBaaSAPINotification.register_notify_callback( + inst_models.persist_instance_fault) + cfg.set_api_config_defaults() + profile.setup_profiler('api', CONF.host) + conf_file = CONF.find_file(CONF.api_paste_config) + LOG.debug("Trove started on %s", CONF.host) + return pastedeploy.paste_deploy_app(conf_file, 'trove', {}) + + +application = wsgimain() diff --git a/trove/cmd/app.wsgi b/trove/cmd/app.wsgi deleted file mode 100644 index a134539c..00000000 --- a/trove/cmd/app.wsgi +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2017 Amrith Kumar. -# All Rights Reserved. -# -# 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. -""" -Used for deploying Trove API through mod-wsgi -""" - -from oslo_log import log as logging -from trove.cmd.common import with_initialize -from trove.common import pastedeploy -from trove.common import profile - -LOG = logging.getLogger('trove.cmd.app') - - -@with_initialize -def wsgimain(CONF): - from trove.common import cfg - from trove.common import notification - from trove.instance import models as inst_models - - notification.DBaaSAPINotification.register_notify_callback( - inst_models.persist_instance_fault) - cfg.set_api_config_defaults() - profile.setup_profiler('api', CONF.host) - conf_file = CONF.find_file(CONF.api_paste_config) - LOG.debug("Trove started on %s", CONF.host) - return pastedeploy.paste_deploy_app(conf_file, 'trove', {}) - -application = wsgimain() -- cgit v1.2.1