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)

[program:happ]
command=sh /home/happ/gunicorn_start
user=happ
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/happ/logs/gunicorn.log

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

#!/bin/bash

NAME="happ"
DIR=/home/happ/happ
USER=happ
GROUP=happ
WORKERS=3
BIND=unix:/home/happ/run/gunicorn.sock
DJANGO_SETTINGS_MODULE=happ.settings
DJANGO_WSGI_MODULE=happ.wsgi
LOG_LEVEL=error

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

export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DIR:$PYTHONPATH

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

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
/home/happ/gunicorn
start: 14: /home/happ/gunicornstart: source: not found
/home/happ/gunicorn
start: 15: /home/happ/gunicornstart:
: not found
/home/happ/gunicorn
start: 18: /home/happ/gunicornstart:
: not found
/home/happ/gunicorn
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.

×
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.

Submit an Answer