Merge "devstack: allow uwsgi deployments"
This commit is contained in:
commit
6ad492eea5
@ -20,6 +20,24 @@ else
|
||||
AODH_BIN_DIR=$(get_python_exec_prefix)
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "$AODH_DEPLOY" ]; then
|
||||
# Default
|
||||
AODH_DEPLOY=werkzeug
|
||||
|
||||
# Fallback to common wsgi devstack configuration
|
||||
if [ "$ENABLE_HTTPD_MOD_WSGI_SERVICES" == "True" ]; then
|
||||
AODH_DEPLOY=mod_wsgi
|
||||
|
||||
# Deprecated config
|
||||
elif [ -n "$AODH_USE_MOD_WSGI" ] ; then
|
||||
echo_summary "AODH_USE_MOD_WSGI is deprecated, use AODH_DEPLOY instead"
|
||||
if [ "$AODH_USE_MOD_WSGI" == True ]; then
|
||||
AODH_DEPLOY=mod_wsgi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Test if any Aodh services are enabled
|
||||
# is_aodh_enabled
|
||||
function is_aodh_enabled {
|
||||
@ -155,7 +173,7 @@ function cleanup_aodh {
|
||||
if [ "$AODH_BACKEND" = 'mongodb' ] ; then
|
||||
mongo aodh --eval "db.dropDatabase();"
|
||||
fi
|
||||
if [ "$AODH_USE_MOD_WSGI" == "True" ]; then
|
||||
if [ "$AODH_DEPLOY" == "mod_wsgi" ]; then
|
||||
_aodh_cleanup_apache_wsgi
|
||||
fi
|
||||
}
|
||||
@ -186,6 +204,16 @@ function configure_aodh {
|
||||
iniset $AODH_CONF coordination backend_url $AODH_COORDINATION_URL
|
||||
fi
|
||||
|
||||
# Set up logging
|
||||
if [ "$SYSLOG" != "False" ]; then
|
||||
iniset $AODH_CONF DEFAULT use_syslog "True"
|
||||
fi
|
||||
|
||||
# Format logging
|
||||
if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ] && [ "$AODH_DEPLOY" != "mod_wsgi" ]; then
|
||||
setup_colorized_logging $AODH_CONF DEFAULT
|
||||
fi
|
||||
|
||||
# Install the policy file for the API server
|
||||
cp $AODH_DIR/etc/aodh/policy.json $AODH_CONF_DIR
|
||||
iniset $AODH_CONF oslo_policy policy_file $AODH_CONF_DIR/policy.json
|
||||
@ -211,9 +239,33 @@ function configure_aodh {
|
||||
|
||||
# NOTE: This must come after database configuration as those can
|
||||
# call cleanup_aodh which will wipe the WSGI config.
|
||||
if [ "$AODH_USE_MOD_WSGI" == "True" ]; then
|
||||
if [ "$AODH_DEPLOY" == "mod_wsgi" ]; then
|
||||
iniset $AODH_CONF api pecan_debug "False"
|
||||
_aodh_config_apache_wsgi
|
||||
elif [ "$AODH_DEPLOY" == "uwsgi" ]; then
|
||||
# iniset creates these files when it's called if they don't exist.
|
||||
AODH_UWSGI_FILE=$AODH_CONF_DIR/aodh-uwsgi.ini
|
||||
|
||||
rm -f "$AODH_UWSGI_FILE"
|
||||
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi http $AODH_SERVICE_HOST:$AODH_SERVICE_PORT
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi wsgi-file "$AODH_DIR/aodh/api/app.wsgi"
|
||||
# This is running standalone
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi master true
|
||||
# Set die-on-term & exit-on-reload so that uwsgi shuts down
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi die-on-term true
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi exit-on-reload true
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi threads 10
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi processes $API_WORKERS
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi enable-threads true
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi plugins python
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi lazy-apps true
|
||||
# uwsgi recommends this to prevent thundering herd on accept.
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi thunder-lock true
|
||||
# Override the default size for headers from the 4k default.
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi buffer-size 65535
|
||||
# Make sure the client doesn't try to re-use the connection.
|
||||
iniset "$AODH_UWSGI_FILE" uwsgi add-header "Connection: close"
|
||||
fi
|
||||
|
||||
if is_service_enabled gnocchi-api; then
|
||||
@ -248,6 +300,12 @@ function install_aodh {
|
||||
install_aodhclient
|
||||
sudo -H pip install -e "$AODH_DIR"[test,$AODH_BACKEND]
|
||||
sudo install -d -o $STACK_USER -m 755 $AODH_CONF_DIR $AODH_API_LOG_DIR
|
||||
|
||||
if [ "$AODH_DEPLOY" == "mod_wsgi" ]; then
|
||||
install_apache_wsgi
|
||||
elif [ "$AODH_DEPLOY" == "uwsgi" ]; then
|
||||
pip_install uwsgi
|
||||
fi
|
||||
}
|
||||
|
||||
# install_aodhclient() - Collect source and prepare
|
||||
@ -263,13 +321,15 @@ function install_aodhclient {
|
||||
|
||||
# start_aodh() - Start running processes, including screen
|
||||
function start_aodh {
|
||||
if [[ "$AODH_USE_MOD_WSGI" == "False" ]]; then
|
||||
run_process aodh-api "$AODH_BIN_DIR/aodh-api -d -v --log-dir=$AODH_API_LOG_DIR --config-file $AODH_CONF"
|
||||
else
|
||||
if [[ "$AODH_DEPLOY" == "mod_wsgi" ]]; then
|
||||
enable_apache_site aodh
|
||||
restart_apache_server
|
||||
tail_log aodh /var/log/$APACHE_NAME/aodh.log
|
||||
tail_log aodh-api /var/log/$APACHE_NAME/aodh_access.log
|
||||
elif [ "$AODH_DEPLOY" == "uwsgi" ]; then
|
||||
run_process aodh-api "$AODH_BIN_DIR/uwsgi $AODH_UWSGI_FILE"
|
||||
else
|
||||
run_process aodh-api "$AODH_BIN_DIR/aodh-api -d -v --log-dir=$AODH_API_LOG_DIR --config-file $AODH_CONF"
|
||||
fi
|
||||
|
||||
# Only die on API if it was actually intended to be turned on
|
||||
@ -287,7 +347,7 @@ function start_aodh {
|
||||
|
||||
# stop_aodh() - Stop running processes
|
||||
function stop_aodh {
|
||||
if [ "$AODH_USE_MOD_WSGI" == "True" ]; then
|
||||
if [ "$AODH_DEPLOY" == "mod_wsgi" ]; then
|
||||
disable_apache_site aodh
|
||||
restart_apache_server
|
||||
fi
|
||||
|
@ -21,7 +21,13 @@ AODH_BACKEND=${AODH_BACKEND:-mysql}
|
||||
AODH_SERVICE_PROTOCOL=http
|
||||
AODH_SERVICE_HOST=$SERVICE_HOST
|
||||
AODH_SERVICE_PORT=${AODH_SERVICE_PORT:-8042}
|
||||
AODH_USE_MOD_WSGI=${AODH_USE_MOD_WSGI:-${ENABLE_HTTPD_MOD_WSGI_SERVICES}}
|
||||
|
||||
# AODH_DEPLOY defines how Aodh is deployed, allowed values:
|
||||
# - mod_wsgi : Run Aodh under Apache HTTPd mod_wsgi
|
||||
# - werkzeug : Run aodh-api
|
||||
# - uwsgi : Run Aodh under uwsgi
|
||||
# - <empty>: Fallback to AODH_USE_MOD_WSGI or ENABLE_HTTPD_MOD_WSGI_SERVICES
|
||||
AODH_DEPLOY=${AODH_DEPLOY}
|
||||
|
||||
# To enable OSprofiler change value of this variable to "notifications,profiler"
|
||||
AODH_NOTIFICATION_TOPICS=${AODH_NOTIFICATION_TOPICS:-notifications}
|
||||
|
@ -26,3 +26,4 @@
|
||||
manual
|
||||
storage
|
||||
mod_wsgi
|
||||
uwsgi
|
||||
|
62
doc/source/install/uwsgi.rst
Normal file
62
doc/source/install/uwsgi.rst
Normal file
@ -0,0 +1,62 @@
|
||||
==============================
|
||||
Installing the API with uwsgi
|
||||
==============================
|
||||
|
||||
Aodh comes with a few example files for configuring the API
|
||||
service to run behind Apache with ``mod_wsgi``.
|
||||
|
||||
app.wsgi
|
||||
========
|
||||
|
||||
The file ``aodh/api/app.wsgi`` sets up the V2 API WSGI
|
||||
application. The file is installed with the rest of the Aodh
|
||||
application code, and should not need to be modified.
|
||||
|
||||
Example of uwsgi configuration file
|
||||
===================================
|
||||
|
||||
|
||||
Create aodh-uwsgi.ini file::
|
||||
|
||||
[uwsgi]
|
||||
http = 0.0.0.0:8041
|
||||
wsgi-file = <path_to_aodh>/aodh/rest/app.wsgi
|
||||
plugins = python
|
||||
# This is running standalone
|
||||
master = true
|
||||
# Set die-on-term & exit-on-reload so that uwsgi shuts down
|
||||
exit-on-reload = true
|
||||
die-on-term = true
|
||||
# uwsgi recommends this to prevent thundering herd on accept.
|
||||
thunder-lock = true
|
||||
# Override the default size for headers from the 4k default. (mainly for keystone token)
|
||||
buffer-size = 65535
|
||||
enable-threads = true
|
||||
# Set the number of threads usually with the returns of command nproc
|
||||
threads = 8
|
||||
# Make sure the client doesn’t try to re-use the connection.
|
||||
add-header = Connection: close
|
||||
# Set uid and gip to a appropriate user on your server. In many
|
||||
# installations ``aodh`` will be correct.
|
||||
uid = aodh
|
||||
gid = aodh
|
||||
|
||||
Then start the uwsgi server::
|
||||
|
||||
uwsgi ./aodh-uwsgi.ini
|
||||
|
||||
Or start in background with::
|
||||
|
||||
uwsgi -d ./aodh-uwsgi.ini
|
||||
|
||||
Limitation
|
||||
==========
|
||||
|
||||
As Aodh is using Pecan and Pecan's DebugMiddleware doesn't support
|
||||
multiple processes, there is no way to set debug mode in the multiprocessing
|
||||
case. To allow multiple processes the DebugMiddleware may be turned off by
|
||||
setting ``pecan_debug`` to ``False`` in the ``api`` section of
|
||||
``aodh.conf``.
|
||||
|
||||
For other WSGI setup you can refer to the `pecan deployment`_ documentation.
|
||||
.. _`pecan deployment`: http://pecan.readthedocs.org/en/latest/deployment.html#deployment
|
Loading…
Reference in New Issue
Block a user