Skip to content

Instantly share code, notes, and snippets.

@timmyomahony
Created June 26, 2011 13:29
Show Gist options
  • Save timmyomahony/1047615 to your computer and use it in GitHub Desktop.
Save timmyomahony/1047615 to your computer and use it in GitHub Desktop.
Python, UWSGI, Supervisor & Nginx
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;
}
}
[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
<uwsgi>
<socket>127.0.0.1:40000</socket>
<processes>2</processes>
<master/>
<post-buffering>4096</post-buffering>
<harakiri>20</harakiri>
</uwsgi>
import os,sys
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'
application = django.core.handlers.wsgi.WSGIHandler()
@weaming
Copy link

weaming commented Mar 28, 2017

stopsignal=INT This helps me!

Actually, I found have to do like this:

/etc/supervisor/conf.d/app.conf

stopsignail = QUIT

/etc/uwsgi/app.ini

processes = 4
master = true

Must set --master when start uwsgi, and supervisor can stop these processed correctly.

See this

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