简体   繁体   中英

How to run background the project Django, use gunicorn?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM