Supervisor always quit process with 'exit status 0; not expected'

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.


Solution 1:

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.

Solution 2:

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