uwsgi improvements
This patch adds a .ini file with the configuration for running mixmatch through uwsgi, replacing the previous `run_proxy.sh` script which passed the configuration as arguments. This patch also removed the wsgi configuration, making it unsupported. The wsgi documentation has also been removed. A follow on patch will also remove any remnants of wsgi logic. The default port for running the proxy has been changed to 9913. This patch also updates the `setup.cfg` file, adding the parameters for wsgi_scripts so that pbr install the wsgi exec on package installation. This patch also uses apache and mod_proxy to map /resource to the uwsgi port 9913. Change-Id: I2069d0f28e8e14da59109158cd2912ddb284a4e3
This commit is contained in:
parent
e860a37ea8
commit
10fae26c6d
@ -12,9 +12,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
MIXMATCH_BIN_DIR=$(get_python_exec_prefix)
|
||||||
|
MIXMATCH_CONF_DIR="/etc/mixmatch"
|
||||||
|
|
||||||
|
MIXMATCH_UWSGI_INI="$MIXMATCH_CONF_DIR/mixmatch-uwsgi.ini"
|
||||||
|
|
||||||
function install_mixmatch {
|
function install_mixmatch {
|
||||||
pip_install $MIXMATCH_DIR
|
pip_install $MIXMATCH_DIR
|
||||||
pip_install uwsgi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_mixmatch {
|
function configure_mixmatch {
|
||||||
@ -23,8 +27,7 @@ function configure_mixmatch {
|
|||||||
sudo chown $STACK_USER:$STACK_USER /etc/mixmatch
|
sudo chown $STACK_USER:$STACK_USER /etc/mixmatch
|
||||||
cp $MIXMATCH_DIR/etc/mixmatch.conf.sample $MIXMATCH_CONF
|
cp $MIXMATCH_DIR/etc/mixmatch.conf.sample $MIXMATCH_CONF
|
||||||
|
|
||||||
iniset $MIXMATCH_CONF database connection "sqlite:////tmp/mixmatch.db"
|
iniset $MIXMATCH_CONF database connection "sqlite://"
|
||||||
iniset $MIXMATCH_CONF DEFAULT port $MIXMATCH_SERVICE_PORT
|
|
||||||
iniset $MIXMATCH_CONF DEFAULT service_providers default
|
iniset $MIXMATCH_CONF DEFAULT service_providers default
|
||||||
iniset $MIXMATCH_CONF DEFAULT aggregation False
|
iniset $MIXMATCH_CONF DEFAULT aggregation False
|
||||||
|
|
||||||
@ -51,21 +54,25 @@ function configure_mixmatch {
|
|||||||
"$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT"
|
"$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT"
|
||||||
iniset $MIXMATCH_CONF sp_default enabled_services "image, volume, network"
|
iniset $MIXMATCH_CONF sp_default enabled_services "image, volume, network"
|
||||||
|
|
||||||
run_process mixmatch "$MIXMATCH_DIR/run_proxy.sh"
|
|
||||||
|
|
||||||
# Nova
|
# Nova
|
||||||
iniset $NOVA_CONF glance api_servers "$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/image"
|
iniset $NOVA_CONF glance api_servers "$MIXMATCH_URL/image"
|
||||||
iniset $NOVA_CONF neutron url "$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/network"
|
iniset $NOVA_CONF neutron url "$MIXMATCH_URL/network"
|
||||||
|
|
||||||
# Cinder
|
# Cinder
|
||||||
iniset $CINDER_CONF DEFAULT glance_api_servers \
|
iniset $CINDER_CONF DEFAULT glance_api_servers "$MIXMATCH_URL/image"
|
||||||
"$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP:$MIXMATCH_SERVICE_PORT/image"
|
|
||||||
iniset $CINDER_CONF oslo_messaging_notifications driver messaging
|
iniset $CINDER_CONF oslo_messaging_notifications driver messaging
|
||||||
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
||||||
|
|
||||||
# Glance
|
# Glance
|
||||||
iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
|
iniset $GLANCE_CONF oslo_messaging_notifications driver messaging
|
||||||
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
iniset $CINDER_CONF oslo_messaging_notifications topics notifications
|
||||||
|
|
||||||
|
sudo cp $MIXMATCH_DIR/httpd/mixmatch-uwsgi.conf $(apache_site_config_for mixmatch)
|
||||||
|
enable_apache_site mixmatch
|
||||||
|
restart_apache_server
|
||||||
|
|
||||||
|
run_process mixmatch \
|
||||||
|
"$MIXMATCH_BIN_DIR/uwsgi --ini $MIXMATCH_DIR/httpd/mixmatch-uwsgi.ini"
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_endpoint_ids {
|
function get_endpoint_ids {
|
||||||
@ -84,36 +91,36 @@ function register_mixmatch {
|
|||||||
get_or_create_endpoint \
|
get_or_create_endpoint \
|
||||||
"image" \
|
"image" \
|
||||||
"$REGION_NAME" \
|
"$REGION_NAME" \
|
||||||
"http://$HOST_IP:5001/image" \
|
"$MIXMATCH_URL/image" \
|
||||||
"http://$HOST_IP:5001/image" \
|
"$MIXMATCH_URL/image" \
|
||||||
"http://$HOST_IP:5001/image"
|
"$MIXMATCH_URL/image"
|
||||||
|
|
||||||
get_or_create_endpoint \
|
get_or_create_endpoint \
|
||||||
"volume" \
|
"volume" \
|
||||||
"$REGION_NAME" \
|
"$REGION_NAME" \
|
||||||
"http://$HOST_IP:5001/volume/v1/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v1/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v1/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v1/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v1/\$(project_id)s"
|
"$MIXMATCH_URL/volume/v1/\$(project_id)s"
|
||||||
|
|
||||||
get_or_create_endpoint \
|
get_or_create_endpoint \
|
||||||
"volumev2" \
|
"volumev2" \
|
||||||
"$REGION_NAME" \
|
"$REGION_NAME" \
|
||||||
"http://$HOST_IP:5001/volume/v2/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v2/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v2/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v2/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v2/\$(project_id)s"
|
"$MIXMATCH_URL/volume/v2/\$(project_id)s"
|
||||||
|
|
||||||
get_or_create_endpoint \
|
get_or_create_endpoint \
|
||||||
"volumev3" \
|
"volumev3" \
|
||||||
"$REGION_NAME" \
|
"$REGION_NAME" \
|
||||||
"http://$HOST_IP:5001/volume/v3/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v3/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v3/\$(project_id)s" \
|
"$MIXMATCH_URL/volume/v3/\$(project_id)s" \
|
||||||
"http://$HOST_IP:5001/volume/v3/\$(project_id)s"
|
"$MIXMATCH_URL/volume/v3/\$(project_id)s"
|
||||||
|
|
||||||
get_or_create_endpoint \
|
get_or_create_endpoint \
|
||||||
"network" \
|
"network" \
|
||||||
"$REGION_NAME" \
|
"$REGION_NAME" \
|
||||||
"http://$HOST_IP:5001/network" \
|
"$MIXMATCH_URL/network" \
|
||||||
"http://$HOST_IP:5001/network" \
|
"$MIXMATCH_URL/network" \
|
||||||
"http://$HOST_IP:5001/network"
|
"$MIXMATCH_URL/network"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ MIXMATCH_DIR=$DEST/mixmatch
|
|||||||
MIXMATCH_PLUGIN=$DEST/mixmatch/devstack
|
MIXMATCH_PLUGIN=$DEST/mixmatch/devstack
|
||||||
MIXMATCH_CONF=/etc/mixmatch/mixmatch.conf
|
MIXMATCH_CONF=/etc/mixmatch/mixmatch.conf
|
||||||
|
|
||||||
MIXMATCH_SERVICE_PORT=${MIXMATCH_SERVICE_PORT:-5001}
|
|
||||||
MIXMATCH_SERVICE_PROTOCOL=${MIXMATCH_SERVICE_PROTOCOL:-http}
|
|
||||||
|
|
||||||
REGISTER_MIXMATCH=${REGISTER_MIXMATCH:-false}
|
REGISTER_MIXMATCH=${REGISTER_MIXMATCH:-false}
|
||||||
|
|
||||||
|
MIXMATCH_SERVICE_PROTOCOL=${MIXMATCH_SERVICE_PROTOCOL:-http}
|
||||||
|
MIXMATCH_URL=${MIXMATCH_URL:-"$MIXMATCH_SERVICE_PROTOCOL://$HOST_IP/resource"}
|
||||||
|
@ -14,27 +14,13 @@ Install dependencies. ::
|
|||||||
|
|
||||||
Web Server
|
Web Server
|
||||||
==========
|
==========
|
||||||
The recommended way is to run the proxy using uWSGI through the
|
The recommended way is to run the proxy using uwsgi and apache through the
|
||||||
``run_proxy.sh`` script. ::
|
`httpd/mixmatch-uwsgi.ini` and `httpd/mixmatch-uwsgi.conf` files respectively ::
|
||||||
|
|
||||||
$ ./run_proxy.sh
|
sudo apt install uwsgi uwsgi-plugin-python libapache2-mod-proxy-uwsgi
|
||||||
|
uwsgi mixmatch/httpd/mixmatch-uwsgi.ini
|
||||||
|
sudo cp mixmatch/httpd/mixmatach-uwsgi.ini /etc/apache2/sites-available/mixmatch.conf
|
||||||
It is also possible to run the proxy with Apache2 and ``mod_wsgi``, but there
|
sudo a2ensite mixmatch
|
||||||
are limitations compared to running it with uWSGI.
|
|
||||||
|
|
||||||
- Image uploading with Glance doesn't work unless running Apache in embedded
|
|
||||||
mode.
|
|
||||||
- Image API v1 uses underscores in the header keys, which are silently dropped
|
|
||||||
by Apache. Hacking the configuration to allow these through is required.
|
|
||||||
|
|
||||||
To run the proxy with Apache in Ubuntu: ::
|
|
||||||
|
|
||||||
$ apt-get install libapache2-mod-wsgi
|
|
||||||
$ cp httpd/apache.conf /etc/apache2/sites-available/proxy.conf
|
|
||||||
$ cp etc/mixmatch.conf.sample /etc/mixmatch/mixmatch.conf
|
|
||||||
$ a2ensite proxy
|
|
||||||
$ service apache2 reload
|
|
||||||
|
|
||||||
|
|
||||||
Running in a Docker Container
|
Running in a Docker Container
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
LoadModule wsgi_module modules/mod_wsgi.so
|
|
||||||
WSGISocketPrefix /var/run/wsgi
|
|
||||||
|
|
||||||
Listen 5001
|
|
||||||
|
|
||||||
<VirtualHost *:5001>
|
|
||||||
WSGIPassAuthorization On
|
|
||||||
WSGIChunkedRequest On
|
|
||||||
#WSGIDaemonProcess k2k-proxy user=ubuntu group=ubuntu threads=2
|
|
||||||
WSGIScriptAlias / /home/ubuntu/k2k-proxy/httpd/k2k-proxy.wsgi
|
|
||||||
|
|
||||||
<Directory /home/ubuntu/k2k-proxy/httpd>
|
|
||||||
#WSGIProcessGroup k2k-proxy
|
|
||||||
#WSGIApplicationGroup %{GLOBAL}
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
@ -1,15 +0,0 @@
|
|||||||
# Copyright 2016 Massachusetts Open Cloud
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
from mixmatch.proxy import app as application
|
|
2
httpd/mixmatch-uwsgi.conf
Normal file
2
httpd/mixmatch-uwsgi.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
KeepAlive Off
|
||||||
|
ProxyPass "/resource" "http://127.0.0.1:9913" retry=0
|
26
httpd/mixmatch-uwsgi.ini
Normal file
26
httpd/mixmatch-uwsgi.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[uwsgi]
|
||||||
|
wsgi-file = /usr/local/bin/mixmatch
|
||||||
|
|
||||||
|
http-socket = 0.0.0.0:9913
|
||||||
|
http-keepalive = false
|
||||||
|
http-chunked-input = true
|
||||||
|
|
||||||
|
# Override the default size for headers from the 4k default.
|
||||||
|
# This is required for keystone tokens.
|
||||||
|
buffer-size = 65535
|
||||||
|
|
||||||
|
# This is running standalone
|
||||||
|
master = true
|
||||||
|
|
||||||
|
enable-threads = true
|
||||||
|
|
||||||
|
# Tune this to your environment.
|
||||||
|
processes = 8
|
||||||
|
|
||||||
|
# uwsgi recommends this to prevent thundering herd on accept.
|
||||||
|
thunder-lock = true
|
||||||
|
|
||||||
|
plugins = python
|
||||||
|
|
||||||
|
# This ensures that file descriptors aren't shared between processes.
|
||||||
|
lazy-apps = true
|
@ -17,10 +17,6 @@ from oslo_config import cfg
|
|||||||
GROUP = None
|
GROUP = None
|
||||||
|
|
||||||
OPTS = [
|
OPTS = [
|
||||||
cfg.IntOpt('port',
|
|
||||||
default=5001,
|
|
||||||
help='Web Server Port'),
|
|
||||||
|
|
||||||
cfg.ListOpt('service_providers',
|
cfg.ListOpt('service_providers',
|
||||||
default=[],
|
default=[],
|
||||||
help='List of service providers'),
|
help='List of service providers'),
|
||||||
|
@ -19,6 +19,7 @@ cd $BASE/new/devstack
|
|||||||
source openrc admin admin
|
source openrc admin admin
|
||||||
|
|
||||||
# Register the endpoints
|
# Register the endpoints
|
||||||
|
source $BASE/new/mixmatch/devstack/settings
|
||||||
source $BASE/new/mixmatch/devstack/mixmatch.sh
|
source $BASE/new/mixmatch/devstack/mixmatch.sh
|
||||||
REGISTER_MIXMATCH=true
|
REGISTER_MIXMATCH=true
|
||||||
register_mixmatch
|
register_mixmatch
|
||||||
|
@ -17,3 +17,7 @@ from mixmatch import session
|
|||||||
|
|
||||||
proxy.main()
|
proxy.main()
|
||||||
application = session.app
|
application = session.app
|
||||||
|
|
||||||
|
|
||||||
|
def get_application():
|
||||||
|
return application
|
||||||
|
10
run_proxy.sh
10
run_proxy.sh
@ -1,10 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
uwsgi --socket 0.0.0.0:5001 \
|
|
||||||
--protocol=http \
|
|
||||||
--http-chunked-input \
|
|
||||||
-w mixmatch.wsgi \
|
|
||||||
--master \
|
|
||||||
--processes 8 \
|
|
||||||
--threads 1 \
|
|
||||||
2>&1
|
|
@ -21,15 +21,22 @@ classifier =
|
|||||||
Programming Language :: Python :: 3.4
|
Programming Language :: Python :: 3.4
|
||||||
Programming Language :: Python :: 3.5
|
Programming Language :: Python :: 3.5
|
||||||
|
|
||||||
|
[global]
|
||||||
|
setup_hooks =
|
||||||
|
pbr.hooks.setup_hook
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages =
|
packages =
|
||||||
mixmatch
|
mixmatch
|
||||||
mixmatch.config
|
mixmatch.config
|
||||||
mixmatch.extend
|
mixmatch.extend
|
||||||
data_files =
|
data_files =
|
||||||
etc/ = etc/*
|
/etc/mixmatch = etc/*
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
|
wsgi_scripts =
|
||||||
|
mixmatch = mixmatch.wsgi:get_application
|
||||||
|
|
||||||
oslo.config.opts =
|
oslo.config.opts =
|
||||||
mixmatch = mixmatch.config:list_opts
|
mixmatch = mixmatch.config:list_opts
|
||||||
mixmatch.extend =
|
mixmatch.extend =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user