7

I'm trying to run a gunicorn_django process in supervisor but it always exits immediately, giving this error:

INFO exited: my_app (exit status 1; not expected)
INFO received SIGCLD indicating a child quit
INFO gave up: my_app entered FATAL state, too many start retries too quickly

My server script looks like this:

#!/bin/bash
set -e
LOGFILE=/var/log/gunicorn/my_app.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
USER=my-www-user
GROUP=my-www-user
cd /home/my-www-user/my_app
source /home/my-www-user/.virtualenvs/my_app/bin/activate
test -d $LOGDIR || mkdir -p $LOGDIR
gunicorn_django -w $NUM_WORKERS --debug \
 --user=$USER --group=$GROUP \
 --log-level=debug --log-file=$LOGFILE 2>>$LOGFILE\
 --pythonpath=my_app --settings=settings.active \
 my_app.wsgi:application

And my supervisor config looks like this:

[program:my_app]
directory=/home/my-www-user/my_app/
user=my-www-user
command=/home/my-www-user/my_app/server.sh
stdout_logfile=/var/log/supervisor/my_app.log
stderr_logfile=/var/log/supervisor/my_app-error.log
autostart=true
autorestart=true

When I su into the my-www-user account the server starts normally. When I do sudo supervisorctl start my_app it simply hangs until I do CTRL-c, then I find the error above in the supervisord.log file.

Does anyone have a clue about what I am missing?

3 Answers 3

3

I seem to have found the solution. I can't have supervisor run my server script as the unprivileged my-www-user since it has to write to log files etc that requires more access. So the solution is to run the server as root and let gunicorn_django spawn the worker process as my-www-user

[program:my_app]
user=root
; rest of config follows
2
  • 2
    This is actually very dangerous, don't do that.
    – Flavian
    Oct 30, 2014 at 12:07
  • @Flavian got an alternative? I am new to this, and that was not something I had anticipated I would face, and while mine runs successfully, it warns me that no user was specified, so it's running as root. I also figure I am right not to worry much since it's running in a docker container and to get into it, you need my root password on host machine
    – Will
    Jun 2, 2018 at 17:53
1

I had this error trying to run ‍Celery, and I had exactly the opposite problem.

I changed my user from root to www-data and that solved it.

1

In my case, having the same error, I debugged it until I found out:

the disk was full and I increased the diskspace to solve this.

(stupid error, easy fix - maybe reading this here helps someone not wasting time)

also linking this questiong for other options:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .