Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

OK I have Django, nginx and uWSGI set up on my server...the problem is I start uWSGI manually via this command:

uwsgi -s /home/user/sites/sock/uwsgi.sock -t 10 -M -p 1 -C --pythonpath /home/user/sites/ -w mysite.django_wsgi

And it's working great. The thing I would like to do is use supervisord to control the uWSGI processes (start, stop, etc.). How would I do this, what would the supervisord config look like?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

I found this was pretty confusing until I discovered emperor mode.

This means you can do one supervisord instance to manage all of your configs:

[program:uwsgi]
command=/usr/local/bin/uwsgi --emperor /etc/uwsgi/apps-enabled
stopsignal=QUIT
autostart=true
autorestart=true
redirect_stderr=true

And then you'd pop any config files (ini, xml, yaml) for apps into the /etc/uwsgi/apps-enabled directory.

Not sure if this works with 0.9, but defintely works with 1.0.

Here's an example ini for a Flask app:

[uwsgi]
socket = /tmp/uwsgi_%n.sock
module = wire:app
chdir = /srv/%n/wire
env = WIRE_SETTINGS=/srv/%n/wire/config.py
virtualenv = /srv/%n
uid = wire
gid = www-data
single-interpreter = false
chmod = 770
processes = 3
share|improve this answer

Have a look at this: http://tracpub.yaco.es/merengue/wiki/Merengue/install/Nginx-WSGI-Virtualenv#Startandstopscripts You maybe have to adapt some parts, but shows how it works ;)

share|improve this answer

Here is a working supervisor conf file (normal mode, not emperor mode) :

[program:frite]
command=/home/mep/envs/frite_prod/bin/uwsgi
  --home frite_prod
  --module frite_deploy_wsgi
  --socket /home/frite/envs/frite_prod/frite.sock
  --chmod-socket 666
  --pythonpath /home/mep/envs/frite_prod/fr-frite
  --pythonpath /home/mep/envs/frite_prod/fr-frite/frite
  --processes 8
  --master -L -l 250 -z 5
  --post-buffering 1
directory=/home/frite/envs/
environment=DJANGO_SETTINGS_MODULE='frite.settings'
user=frite
autostart=true
autorestart=true
stdout_logfile=/home/frite/envs/frite_prod/uwsgi.log
redirect_stderr=true
stopsignal=QUIT

Your app need to be installed in a virtualenv. (And in this example I have the app running as "frite" user. So I have created a unix user with sudo addusr or something and put the virtualenvs and files there. So that it's isolated from the rest of the system.

And frite_deploy_wsgi.py is a kind of launcher that contains only :

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Cheers

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.