From da700b710f1c78b4a17f962a71eb6200399fa050 Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Mon, 14 Jan 2019 21:37:56 +0000 Subject: [PATCH] Add uWSGI configuration samples Added some samples on uWSGI config and some docs on how to run manila with uWSGI for contributors. Partially-implements: blueprint wsgi-web-servers-support Change-Id: I8e68619b00255197b3d3cf6796c60d1a3a04ff36 (cherry picked from commit 7a1414977f1f1699b000ff04ed0e0d32853d1185) (cherry picked from commit 8f5d81586ead346c6cde995d7baf2910663f7211) (cherry picked from commit ecb9d6396c529bbcba861f205932f4b45a67d1af) --- doc/source/contributor/apache-httpd.rst | 79 +++++++++++++++++++++++++ doc/source/contributor/index.rst | 1 + httpd/manila-uwsgi.ini | 18 ++++++ httpd/uwsgi-manila.conf | 3 + 4 files changed, 101 insertions(+) create mode 100644 doc/source/contributor/apache-httpd.rst create mode 100644 httpd/manila-uwsgi.ini create mode 100644 httpd/uwsgi-manila.conf diff --git a/doc/source/contributor/apache-httpd.rst b/doc/source/contributor/apache-httpd.rst new file mode 100644 index 0000000000..29f22a9e04 --- /dev/null +++ b/doc/source/contributor/apache-httpd.rst @@ -0,0 +1,79 @@ +==================================== +Running manila API with a web server +==================================== + +As part of the `community goals for Pike`_, manila has packaged +a wsgi script entrypoint that allows you to run it with a real web server +like Apache HTTPD or NGINX. + +This doc shows a sample of deploying manila with uwsgi + +Installing the API via uwsgi +----------------------------- + +For this deployment we use uwsgi as a web server bound to a random +local port. Then we configure apache using mod_proxy to forward all incoming +requests on the specified endpoint to that local webserver. This has the +advantage of letting apache manage all inbound http connections, but allowing +uwsgi run the python code. This also means that when we make +changes to manila code or configuration we don't need to restart all of apache +(which may be running other services as well) and just need to restart the local +uwsgi daemon. + +The httpd/ directory contains sample files for configuring HTTPD to run manila +under uwsgi. To use sample configs, simply copy `httpd/uwsgi-manila.conf` to the +appropiate location for your apache server. + +On RHEL/CentOS/Fedora it is:: + + /etc/httpd/conf.d/uwsgi-manila.conf + +On SLES/OpenSUSE it is:: + + /etc/apache2/vhosts.d/uwsgi-manila.conf + +On Debian/Ubuntu it is:: + + /etc/apache2/sites-available/uwsgi-manila.conf + +Enable mod_proxy by running ``sudo a2enmod proxy`` + +On Ubuntu/Debian systems enable the site using the a2ensite tool:: + + sudo a2ensite /etc/apache2/sites-available/uwsgi-manila.conf + +This is not required on RHEL/CentOS/Fedora systems. + +Start or restart HTTPD/Apache2 to pick up the new configuration. + +Now we have to configure and start the uwsgi service. +Copy the `httpd/manila-uwsgi.ini` file to `/etc/manila`. Update the file to +match your system configuration (i.e. tweak the number of processes and threads) + +Install uwsgi. + +On RHEL/CentOS:: + + sudo yum install uwsgi-plugin-python3 + +On Fedora:: + + sudo dnf install uwsgi-plugin-python3 + +On SLES/OpenSUSE:: + + sudo zypper install uwsgi-python3 + +On Ubuntu/Debian:: + + sudo apt-get install uwsgi-plugin-python3 + +And start the manila server using uwsgi:: + + uwsgi --ini /etc/manila/manila-uwsgi.ini + +.. NOTE:: + + In the sample configs port 51999 is used, this is a randomly selected number. + +.. _community goals for Pike: https://governance.openstack.org/tc/goals/pike/deploy-api-in-wsgi.html#control-plane-api-endpoints-deployment-via-wsgi diff --git a/doc/source/contributor/index.rst b/doc/source/contributor/index.rst index 0b06f6da70..fa18d3b09f 100644 --- a/doc/source/contributor/index.rst +++ b/doc/source/contributor/index.rst @@ -28,6 +28,7 @@ Programming HowTos and Tutorials development.environment development-environment-devstack + apache-httpd unit_tests tempest_tests addmethod.openstackapi diff --git a/httpd/manila-uwsgi.ini b/httpd/manila-uwsgi.ini new file mode 100644 index 0000000000..8e723fd1df --- /dev/null +++ b/httpd/manila-uwsgi.ini @@ -0,0 +1,18 @@ +[uwsgi] +socket-timeout = 10 +http-auto-chunked = true +http-chunked-input = true +http-raw-body = true +chmod-socket = 666 +lazy-apps = true +add-header = Connection: close +buffer-size = 65535 +thunder-lock = true +plugins = python +enable-threads = true +exit-on-reload = true +die-on-term = true +master = true +processes = 4 +http-socket = 127.0.0.1:61999 +wsgi-file = /usr/local/bin/manila-wsgi-api diff --git a/httpd/uwsgi-manila.conf b/httpd/uwsgi-manila.conf new file mode 100644 index 0000000000..c3881b20bc --- /dev/null +++ b/httpd/uwsgi-manila.conf @@ -0,0 +1,3 @@ +KeepAlive Off +SetEnv proxy-sendchunked 1 +ProxyPass "/share" "http://127.0.0.1:51999" retry=0