Django Deployment - issue with supervisor failing (exited too quickly)

Posted September 7, 2018 3.6k views
NginxDjangoDeploymentUbuntu 18.04

Hi everyone! I’m on my first Django deployment on Digital Ocean and I can’t seem to get past an error that’s rising when I check the status of supervisor.

here’s my happ.conf file (/etc/supervisor/conf.d.happ.conf)

command=sh /home/happ/gunicorn_start

and here’s my gunicornstart file (/home/happ/gunicornstart)



cd $DIR
source ../venv/bin/activate


exec ../venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $WORKERS \
  --user=$USER \
  --group=$GROUP \
  --bind=$BIND \
  --log-level=$LOG_LEVEL \

Firstly I make the file executable:

chmod u+x gunicorn_start

Then I run the following commands:

sudo supervisorctl reread
sudo supervisorctl update

sudo supervisorctl status happ

And once I run the status command I get the following error:

Exited too quickly.

Here’s what the log file says:

/home/happ/gunicornstart: 2: /home/happ/gunicornstart:
: not found
/home/happ/gunicornstart: 12: /home/happ/gunicornstart:
: not found
/home/happ/gunicornstart: 13: cd: can’t cd to /home/happ/happ
start: 14: /home/happ/gunicornstart: source: not found
start: 15: /home/happ/gunicornstart:
: not found
start: 18: /home/happ/gunicornstart:
: not found
start: 19: exec: ../venv/bin/gunicorn: not found
Please note that the above commands are run inside the console not by the user root but by a user I created which is added to the sudoers list.

If anyone has any hint, please feel free to help out as I’ve been stuck on this issue for two days and I don’t really know where else to look for a solution. Thank you very much.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

I bet you are following the “simple is better than complex” “tutorial”. Actually people have been stuck with that issue for years. Nobody knows how to solve it and has made thousands of people quit the attempt to launch the app as it should with gunicorn and supervisor.
There are countless of “tutorials” doing as if they were tutorials by presenting “how to properly configure and set up a full fledged django app in a production server”, but, why would they want to tell you how to do it? you would become a competitor and snatch jobs from them, so what they do is deliberately leave bugs that you will never be able to solve, so you can’t launch the application. They write tutorials to make a name for themselves, but not to teach you.