Merge "Add support for running the main WSGI application from a virtualenv"

This commit is contained in:
Zuul 2018-06-01 21:03:51 +00:00 committed by Gerrit Code Review
commit 16bf9124eb
1 changed files with 25 additions and 4 deletions

View File

@ -15,14 +15,35 @@
# You should have received a copy of the GNU General Public License
# along with ARA. If not, see <http://www.gnu.org/licenses/>.
# WSGI file to run the ARA server, it is expected that the server passes an
# ANSIBLE_CONFIG environment variable in order to configure Ansible and ARA.
# WSGI file to run the ARA server.
# It is expected that the server at least passes an ANSIBLE_CONFIG environment
# variable in order to configure Ansible and ARA.
# Can be configured using environment variables (i.e, Apache SetEnv) with the
# following variables:
# ARA_WSGI_USE_VIRTUALENV
# Enable virtual environment usage if ARA is installed in a virtual
# environment.
# Defaults to '0', set to '1' to enable.
# ARA_WSGI_VIRTUALENV_PATH
# When using a virtual environment, where the virtualenv is located.
# Defaults to None, set to the absolute path of your virtualenv.
import os
import logging
import six
from ara.webapp import create_app
from flask import current_app
if (int(os.getenv('ARA_WSGI_USE_VIRTUALENV', 0)) == 1 and
os.getenv('ARA_WSGI_VIRTUALENV_PATH')):
activate_this = os.getenv('ARA_WSGI_VIRTUALENV_PATH')
if six.PY2:
execfile(activate_this, dict(__file__=activate_this)) # nosec
else:
exec(open(activate_this).read()) # nosec
from ara.webapp import create_app # flake8: noqa
from flask import current_app # flake8: noqa
log = logging.getLogger(__name__)
app = create_app()