Why use uwsgi
Not all OpenStack services support uwsgi. However, in the Liberty timeframe it is supported as the primary way to run Keystone api services and recommended way of running Horizon (if you use it). Going forward other openstack services will be movnig to support it as well, for instance I know that Neutron is working on it or have it completed for the Mitaka release.
Basic Setup
- Install
>=www-servers/uwsgi-2.0.11.2-r1
with thepython
use flag as it has an updated init script. - Make sure you note the group you want for the webserver to access the uwsgi sockets, I chose nginx.
Configs and permissions
When defaults are available I will only note what needs to change.
uwsgi configs
/etc/conf.d/uwsgi
UWSGI_EMPEROR_PATH="/etc/uwsgi.d/"
UWSGI_EMPEROR_GROUP=nginx
UWSGI_EXTRA_OPTIONS='--need-plugins python27'
/etc/uwsgi.d/keystone-admin.ini
[uwsgi]
master = true
plugins = python27
processes = 10
threads = 2
chmod-socket = 660
socket = /run/uwsgi/keystone_admin.socket
pidfile = /run/uwsgi/keystone_admin.pid
logger = file:/var/log/keystone/uwsgi-admin.log
name = keystone
uid = keystone
gid = nginx
chdir = /var/www/keystone/
wsgi-file = /var/www/keystone/admin
/etc/uwsgi.d/keystone-main.ini
[uwsgi]
master = true
plugins = python27
processes = 4
threads = 2
chmod-socket = 660
socket = /run/uwsgi/keystone_main.socket
pidfile = /run/uwsgi/keystone_main.pid
logger = file:/var/log/keystone/uwsgi-main.log
name = keystone
uid = keystone
gid = nginx
chdir = /var/www/keystone/
wsgi-file = /var/www/keystone/main
I have horizon in use via a virtual environment so enabled vaccum in this config.
/etc/uwsgi.d/horizon.ini
[uwsgi]
master = true
plugins = python27
processes = 10
threads = 2
chmod-socket = 660
vacuum = true
socket = /run/uwsgi/horizon.sock
pidfile = /run/uwsgi/horizon.pid
log-syslog = file:/var/log/horizon/horizon.log
name = horizon
uid = horizon
gid = nginx
chdir = /var/www/horizon/
wsgi-file = /var/www/horizon/horizon.wsgi
wsgi scripts
The directories are owned by the serverice they are containing, keystone:keystone or horizon:horizon.
/var/www/keystone/admin
perms are 0750 keystone:keystone
# Copyright 2013 OpenStack Foundation
#
# 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.
import os
from keystone.server import wsgi as wsgi_server
name = os.path.basename(__file__)
# NOTE(ldbragst): 'application' is required in this context by WSGI spec.
# The following is a reference to Python Paste Deploy documentation
# http://pythonpaste.org/deploy/
application = wsgi_server.initialize_application(name)
/var/www/keystone/main
perms are 0750 keystone:keystone
# Copyright 2013 OpenStack Foundation
#
# 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.
import os
from keystone.server import wsgi as wsgi_server
name = os.path.basename(__file__)
# NOTE(ldbragst): 'application' is required in this context by WSGI spec.
# The following is a reference to Python Paste Deploy documentation
# http://pythonpaste.org/deploy/
application = wsgi_server.initialize_application(name)
Note that this has paths to where I have my horizon virtual environment.
/var/www/horizon/horizon.wsgi
perms are 0750 horizon:horizon
#!/usr/bin/env python
import os
import sys
activate_this = '/home/horizon/horizon/.venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path.insert(0, '/home/horizon/horizon')
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
import django.core.wsgi
application = django.core.wsgi.get_wsgi_application()