1

I use gunicorn to deploy project Django background.

python2.7 manage.py run_gunicorn 0.0.0.0:8090

It is not run background.

gunicorn_django -b 0.0.0.0:8090

It doesn't see the my apps.

The project ran successfully when python manage.py runserver

Hueston Rido
  • 809
  • 1
  • 11
  • 16

1 Answers1

0

To run gunicorn in background you will need to use a process control system like Supervisord to manage gunicorn.

Deployment instructions with Supervisor and/or Runit are described here

For the part of problem where the apps are not detected, did you add gunicorn to your INSTALLED_APPS setting in django settings.py? If not integration is decribed here

Edit:

Sample gunicorn management script for supervisor

#!/bin/bash
set -e
    LOGFILE=/home/ubuntu/logs/gunicorn/x.log
    LOGDIR=$(dirname $LOGFILE)
    NUM_WORKERS=3
    HOST=0.0.0.0:8000
    # user/group to run as
    USER=ubuntu
    GROUP=ubuntu
    cd ~/webapps/Z/
    . ~/virtualenvs/production/bin/activate
    test -d $LOGDIR || mkdir -p $LOGDIR
    exec ~/virtualenvs/production/bin/gunicorn_django -b $HOST -w $NUM_WORKERS \
        --user=$USER --group=$GROUP --log-level=debug \
        --log-file=$LOGFILE 2>>$LOGFILE
Pratik Mandrekar
  • 9,362
  • 4
  • 45
  • 65
  • I installed ang ran supervisor. When i ran `python2.7 manage.py run_gunicorn 0.0.0.0:8090 - w 2 --preload --daemon --user=htk --group=htk --log-level=debug --log-file=/home/htk/workspace/testproject/testproject.log 2>>/home/htk/workspace/testproject/testproject.log` It logged: `Error: Usage is runserver [optional port number, or ipaddr:port or unix:/path/to/sockfile]` – Hueston Rido Oct 05 '12 at 10:22
  • Your usage is incorrect, run `gunicorn_django` directly without the `python manage.py` – Pratik Mandrekar Oct 05 '12 at 10:38