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

I'm currently rebuilding my vps, and I'd like to use supervisor for managing my gunicorn/wsgi django processes. Thing is, supervisor keeps exiting the processes:

2010-07-23 14:54:40,575 INFO supervisord started with pid 31391
2010-07-23 14:54:41,582 INFO spawned: 'projectx' with pid 31395
2010-07-23 14:54:41,691 INFO exited: projectx (exit status 0; not expected)
2010-07-23 14:54:42,695 INFO spawned: 'projectx' with pid 31401
2010-07-23 14:54:42,801 INFO exited: projectx (exit status 0; not expected)
2010-07-23 14:54:44,806 INFO spawned: 'projectx' with pid 31404
2010-07-23 14:54:44,912 INFO exited: projectx (exit status 0; not expected)
2010-07-23 14:54:47,917 INFO spawned: 'projectx' with pid 31408
2010-07-23 14:54:48,022 INFO exited: projectx (exit status 0; not expected)
2010-07-23 14:54:49,023 INFO gave up: projectx entered FATAL state, too many start retries too quickly

This is the config I'm using:

[program:projectx]
command=/path/to/project/bin/gunicorn_django -c /path/to/project/project/gunicorn.conf.py /path/to/project/project/production.py
user=myuser
autostart=true
autorestart=true

I already double checked, and gunicorn_django does return status 0 when it's spawned correctly.

I tried adding exitcodes=0,2 explicitly to the config, but that doesn't seem to make a difference either. It looks like the process is spawned correctly, but supervisor thinks it didn't.

Does anyone have a clue on how to solve this?

Thanks, Bjorn

share|improve this question

3 Answers 3

If gunicorn_django is daemonizing itself, it's not the kind of program supervisor is designed to manage. Supervisor expects its supervised programs to run in the foreground so it can monitor if they've exited.

See supervisord docs.

share|improve this answer
    
gunicorn doesn't deamonize itself by default, but I did set it in my configuration file. I removed it, thanks for pointing that out. –  Bjorn Jul 23 '10 at 19:02
up vote 1 down vote accepted

Ok, after some puzzling I figured out it had something to do with users. I tried to run my child processes as a certain user. After removing the line (see my config below), everything is working fine.

Gunicorn config:

bind = "127.0.0.1:3305"
workers = 2

Supervisor config:

[program:projectx]
command=/path/to/project/bin/gunicorn_django -c /path/to/project/project/gunicorn.conf.py /path/to/project/project/production.py
; set the user here instead of in the gunicorn config.
user=user
autostart=true
autorestart=unexpected
stdout_logfile=/path/to/project/logs/project.log
redirect_stderr=true
exitcodes=1
share|improve this answer
1  
Just a quick note that if you want to flesh this out, su'ing to myuser and running gunicorn should give a hint. The usual suspects are the log and pid files not being writable. Alternatively, your app might need file permissions as well. And just a quick note that for better supervisor support you should upgrade to 0.10 as we fixed an issue with restarting gunicorn via supervisord (or runit for that matter). –  Paul J. Davis Jul 31 '10 at 3:39

I got a similar error when trying to execute an http daemon under supervisor.

Fixed by removing the old pid file: httpd_pid

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.