Created
June 26, 2011 13:29
-
-
Save timmyomahony/1047615 to your computer and use it in GitHub Desktop.
Python, UWSGI, Supervisor & 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
upstream uwsgi { | |
ip_hash; | |
server 127.0.0.1:40000; | |
} | |
server { | |
listen 80; | |
server_name www.domain.com; | |
root /sites/mysite/; | |
access_log /sites/mysite/log/nginx/access.log; | |
error_log /sites/mysite/log/nginx/error.log; | |
location /media/ { | |
alias /sites/mysite/media/; | |
} | |
location /static/ { | |
alias /sites/mysite/static/; | |
} | |
location / { | |
include uwsgi_params; | |
uwsgi_pass uwsgi; | |
uwsgi_param UWSGI_PYHOME $document_root; | |
uwsgi_param UWSGI_CHDIR $document_root/project_root; | |
uwsgi_param UWSGI_SCRIPT confs.django_wsgi; | |
} | |
} | |
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
[program:uwsgi] | |
user = uwsgi | |
command=/opt/bin/uwsgi --xmlconfig=/sites/mywebsite/myproject/confs/uwsgi.xml | |
autostart=true | |
autorestart=true | |
stderr_logfile = /sites/mywebsite/log/uwsgi/err.log | |
stdout_logfile = /sites/mywebsite/log/uwsgi/out.log | |
stopsignal=INT |
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
<uwsgi> | |
<socket>127.0.0.1:40000</socket> | |
<processes>2</processes> | |
<master/> | |
<post-buffering>4096</post-buffering> | |
<harakiri>20</harakiri> | |
</uwsgi> |
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
import os,sys | |
import django.core.handlers.wsgi | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production' | |
application = django.core.handlers.wsgi.WSGIHandler() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stopsignal=INT
This helps me!Actually, I found have to do like this:
/etc/supervisor/conf.d/app.conf
/etc/uwsgi/app.ini
Must set
--master
when start uwsgi, and supervisor can stop these processed correctly.See this