-
-
Save shawn-sterling/1830615 to your computer and use it in GitHub Desktop.
Graphite on uwsgi/nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting 502 errors when I emulate your configuration on a (mostly) vanilla 12.04 AMI on EC2. Any idea what might be causing this?
ps -ef | grep graphite
returns:nobody su -s /bin/sh -c /usr/local/bin/pystatsd-server --port 8125 --pct 90 --graphite-host localhost --graphite-port 2003 nobody
nobody sh -c /usr/local/bin/pystatsd-server --port 8125 --pct 90 --graphite-host localhost --graphite-port 2003
nobody /usr/bin/python /usr/local/bin/pystatsd-server --port 8125 --pct 90 --graphite-host localhost --graphite-port 2003
graphite /usr/bin/python /opt/graphite/bin/carbon-cache.py start
www-data /usr/local/bin/uwsgi --ini /etc/uwsgi/graphite.ini
What's odd is that the configuration I am using in production works just fine, but when I
knife ec2 server create
another instance with the same role, it returns 502 when I try to access it (though I am accessing it from the raw ec2-address, but that shouldn't make a difference).