Skip to content

Instantly share code, notes, and snippets.

@jharley
Last active August 29, 2015 14:02
Show Gist options
  • Save jharley/e23034135966bb7b438e to your computer and use it in GitHub Desktop.
Save jharley/e23034135966bb7b438e to your computer and use it in GitHub Desktop.
ceph REST API: upstart+uwsgi+nginx
# /etc/nginx/sites-available/ceph-rest-api
server {
listen 80;
server_name ceph-rest-api;
charset utf-8;
location / {
root /var/log/nginx;
error_log /var/log/nginx/ceph-restapi-error.log;
access_log /var/log/nginx/ceph-restapi-access.log combined;
include uwsgi_params;
uwsgi_pass unix:/var/lib/nginx/uwsgi/ceph-restapi.sock;
}
}
# /etc/init/ceph-restapi.conf
description "Ceph REST API uWSGI Container"
start on runlevel [2345]
stop on runlevel [06]
respawn
exec /usr/bin/uwsgi --ini /etc/ceph/restapi-uwsgi.ini
'''
/etc/nginx/uwsgi-wrapper/ceph-restapi.wsgi
WSGI wrapper for the Ceph REST API
Taken from Wido den Hollander's helpful Gist: https://gist.github.com/wido/8bf032e5f482bfef949c
'''
conffile="/etc/ceph/ceph.conf"
cluster="ceph"
clientname=None
clientid="admin"
args=None
try:
import ceph_rest_api
except EnvironmentError as e:
print >> sys.stderr, "Error importing ceph_rest_api: ", str(e)
sys.exit(1)
application = ceph_rest_api.generate_app(
conffile,
cluster,
clientname,
clientid,
args,
)
# /etc/ceph/restapi-uwsgi.ini
[uwsgi]
uid = root
gid = www-data
logdate = yes
die-on-term = yes
socket = /var/lib/nginx/uwsgi/ceph-restapi.sock
chmod-socket = 660
plugin = python
enable-threads = yes
wsgi-file = /etc/nginx/uwsgi-wrapper/ceph-restapi.wsgi
callable = application
need-app = yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment