Create new wsgi.py file and deprecate old file
Django 1.4 stopped creating django.wsgi files and the common practice now for a while has been a wsgi.py since it is actually python code, and should actually be importable. Right now someone has to copy and rename the existing file if they want to use it with a server like gunicorn. This patch adds a new file in location that is importable via python and adds a deprecation log to the old one. This also updates the wsgi generation commands to instead create 'horizon_wsgi.py' and have the apache conf generation also use that or the default wsgi file. Change-Id: I0f8bd16c8973ad23bcd8f73b54584dc69e5aed0c Closes-Bug: #1763204
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,6 +31,7 @@ openstack_dashboard/test/.secret_key_store
|
|||||||
openstack_dashboard/test/integration_tests/local-horizon.conf
|
openstack_dashboard/test/integration_tests/local-horizon.conf
|
||||||
openstack_dashboard/test/integration_tests/test_reports/
|
openstack_dashboard/test/integration_tests/test_reports/
|
||||||
openstack_dashboard/wsgi/horizon.wsgi
|
openstack_dashboard/wsgi/horizon.wsgi
|
||||||
|
openstack_dashboard/horizon_wsgi.py
|
||||||
doc/build/
|
doc/build/
|
||||||
/static/
|
/static/
|
||||||
integration_tests_screenshots/
|
integration_tests_screenshots/
|
||||||
|
@@ -341,10 +341,10 @@ Use a domain that fits your current setup.
|
|||||||
|
|
||||||
.. code-block:: apacheconf
|
.. code-block:: apacheconf
|
||||||
|
|
||||||
WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
|
WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
|
||||||
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
||||||
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
||||||
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
|
<Directory /usr/share/openstack-dashboard/openstack_dashboard>
|
||||||
# For Apache http server 2.2 and earlier:
|
# For Apache http server 2.2 and earlier:
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
Allow from all
|
Allow from all
|
||||||
@@ -385,10 +385,10 @@ Use a domain that fits your current setup.
|
|||||||
# wire
|
# wire
|
||||||
Header add Strict-Transport-Security "max-age=15768000"
|
Header add Strict-Transport-Security "max-age=15768000"
|
||||||
|
|
||||||
WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
|
WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi.py
|
||||||
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10
|
||||||
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
|
||||||
<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
|
<Directory /usr/share/openstack-dashboard/openstack_dashboard>
|
||||||
# For Apache http server 2.2 and earlier:
|
# For Apache http server 2.2 and earlier:
|
||||||
<ifVersion <2.4>
|
<ifVersion <2.4>
|
||||||
Order allow,deny
|
Order allow,deny
|
||||||
|
@@ -170,8 +170,8 @@ Deployment
|
|||||||
|
|
||||||
$ sudo apt-get install apache2 libapache2-mod-wsgi
|
$ sudo apt-get install apache2 libapache2-mod-wsgi
|
||||||
|
|
||||||
You can either use the provided ``openstack_dashboard/wsgi/django.wsgi`` or
|
You can either use the provided ``openstack_dashboard/wsgi.py`` or
|
||||||
generate a ``openstack_dashboard/wsgi/horizon.wsgi`` file with the following
|
generate a ``openstack_dashboard/horizon_wsgi.py`` file with the following
|
||||||
command (which detects if you use a virtual environment or not to
|
command (which detects if you use a virtual environment or not to
|
||||||
automatically build an adapted WSGI file)
|
automatically build an adapted WSGI file)
|
||||||
|
|
||||||
@@ -184,8 +184,9 @@ Deployment
|
|||||||
``/etc/apache2/sites-available/horizon.conf``.
|
``/etc/apache2/sites-available/horizon.conf``.
|
||||||
The template in DevStack is a good example of the file.
|
The template in DevStack is a good example of the file.
|
||||||
http://git.openstack.org/cgit/openstack-dev/devstack/tree/files/apache-horizon.template
|
http://git.openstack.org/cgit/openstack-dev/devstack/tree/files/apache-horizon.template
|
||||||
Or, if you previously generated an ``openstack_dashboard/wsgi/horizon.wsgi``
|
Or you can automatically generate an apache configuration file. If you
|
||||||
you can automatically generate an apache configuration file
|
previously generated an ``openstack_dashboard/horizon_wsgi.py`` file it will
|
||||||
|
use that, otherwise will default to using ``openstack_dashboard/wsgi.py``
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
|
@@ -85,8 +85,10 @@ context['PROJECT_DIR_NAME'] = os.path.basename(
|
|||||||
context['PROJECT_PATH'].split(context['PROJECT_ROOT'])[1])
|
context['PROJECT_PATH'].split(context['PROJECT_ROOT'])[1])
|
||||||
context['PROJECT_NAME'] = context['PROJECT_DIR_NAME']
|
context['PROJECT_NAME'] = context['PROJECT_DIR_NAME']
|
||||||
|
|
||||||
|
context['DEFAULT_WSGI_FILE'] = os.path.join(
|
||||||
|
context['PROJECT_PATH'], 'wsgi.py')
|
||||||
context['WSGI_FILE'] = os.path.join(
|
context['WSGI_FILE'] = os.path.join(
|
||||||
context['PROJECT_PATH'], 'wsgi/horizon.wsgi')
|
context['PROJECT_PATH'], 'horizon_wsgi.py')
|
||||||
|
|
||||||
VHOSTNAME = context['HOSTNAME'].split('.')
|
VHOSTNAME = context['HOSTNAME'].split('.')
|
||||||
VHOSTNAME[0] = context['PROJECT_NAME']
|
VHOSTNAME[0] = context['PROJECT_NAME']
|
||||||
@@ -316,6 +318,10 @@ location you desire, e.g.::
|
|||||||
|
|
||||||
# Generate the apache configuration.
|
# Generate the apache configuration.
|
||||||
elif options.get('apache'):
|
elif options.get('apache'):
|
||||||
|
# first check if custom wsgi file exists, if not, use default:
|
||||||
|
if not os.path.exists(context['WSGI_FILE']):
|
||||||
|
context['WSGI_FILE'] = context['DEFAULT_WSGI_FILE']
|
||||||
|
|
||||||
with open(
|
with open(
|
||||||
os.path.join(CURDIR, 'apache_vhost.conf.template'), 'r'
|
os.path.join(CURDIR, 'apache_vhost.conf.template'), 'r'
|
||||||
) as fp:
|
) as fp:
|
||||||
|
29
openstack_dashboard/wsgi.py
Normal file
29
openstack_dashboard/wsgi.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
WSGI config for openstack_dashboard project.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
# Add this file path to sys.path in order to import settings
|
||||||
|
sys.path.insert(0, os.path.normpath(os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)), '../..')))
|
||||||
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
|
||||||
|
sys.stdout = sys.stderr
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
@@ -17,6 +17,7 @@
|
|||||||
WSGI config for openstack_dashboard project.
|
WSGI config for openstack_dashboard project.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -28,6 +29,12 @@ sys.path.insert(0, os.path.normpath(os.path.join(
|
|||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
|
||||||
sys.stdout = sys.stderr
|
sys.stdout = sys.stderr
|
||||||
|
|
||||||
DEBUG = False
|
logging.warning(
|
||||||
|
"Use of this 'djano.wsgi' file has been deprecated since the Rocky "
|
||||||
|
"release in favor of 'wsgi.py' in the 'openstack_dashboard' module. This "
|
||||||
|
"file is a legacy naming from before Django 1.4 and an importable "
|
||||||
|
"'wsgi.py' is now the default. This file will be removed in the T release "
|
||||||
|
"cycle."
|
||||||
|
)
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
[:bug:`1763204`]
|
||||||
|
Use of this 'djano.wsgi' file has been deprecated since the Rocky
|
||||||
|
release in favor of 'wsgi.py' in the 'openstack_dashboard' module. This
|
||||||
|
file is a legacy naming from before Django 1.4 and an importable
|
||||||
|
'wsgi.py' is now the default. This file will be removed in the T release
|
||||||
|
cycle.
|
Reference in New Issue
Block a user