Skip to content

Instantly share code, notes, and snippets.

@drawks
Created February 14, 2012 21:24
Show Gist options
  • Star 46 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save drawks/1830579 to your computer and use it in GitHub Desktop.
Save drawks/1830579 to your computer and use it in GitHub Desktop.
Graphite on uwsgi/nginx
#This is the "site config" for nginx
upstream django {
# Distribute requests to servers based on client IP. This keeps load
# balancing fair but consistent per-client. In this instance we're
# only using one uWGSI worker anyway.
ip_hash;
server unix:/tmp/uwsgi.sock;
}
server {
listen 8080;
server_name graphite;
charset utf-8;
# Django admin media.
location /media/admin/ {
alias /usr/lib/python2.7/site-packages/django/contrib/admin/media/;
}
# Your project's static media.
location /content/ {
alias /usr/share/graphite/webapp/content/;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include uwsgi_params;
}
}
#This is the uwsgi configfile
[uwsgi]
vacuum = true
master = true
processes = 8
pidfile = /tmp/uwsgi.pid
socket = /tmp/uwsgi.sock
chmod-socket = 666
gid = www-data
uid = www-data
pythonpath = /usr/share/graphite/webapp
home = /home/drawks/graphite-sb
pymodule-alias = graphite.local_settings=/etc/graphite/local_settings.py
module = wsgi
buffer-size = 65536
#This is the wsgi target that lives under the webapp subdirectory
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
@kbalasun
Copy link

kbalasun commented Feb 5, 2015

great. Really helpful.

@vlcty
Copy link

vlcty commented Nov 6, 2015

Nice! Thanks

@harshitanand
Copy link

great stuff

@anirbanroydas
Copy link

@drawks This wsgi.py file you have mentioned, it doesn't exist in the /opt/graphite/webapp directory, so do I have to add this file exclusively?

@leoleovich
Copy link

What is the point of https://gist.github.com/drawks/1830579#file-graphite-L7 when you are using 1 server? To be honest what is the point to have upstream at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment