我正试图制作一个gunicorn bash可执行文件来运行django服务器,但出现错误-gunicorn: error: argument --error-logfile/--log-file: expected one argument
。
它可以与-gunicorn bekaim_pre_registration.wsgi:application --bind 0.0.0.0:8001
一起正常使用
但是bash文件出错。
这是我的-gunicorn_start.bash
#!/bin/bash
NAME="django_app" # Name of the application
DJANGODIR=/home/ubuntu/bekaim_pre_registration # Django project directory
SOCKFILE=/home/ubuntu/django_env/run/gunicorn.sock # we will communicte using this unix socket
USER=ubuntu # the user to run as
GROUP=ubuntu # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bekaim_pre_registration.settings # which settings file should Django use
DJANGO_WSGI_MODULE=bekaim_pre_registration.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/ubuntu/django_env/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file
使此脚本可执行。
$ sudo chmod u+x gunicorn_start.bash
我测试时-./gunicorn_start.bash
Starting django_app as ubuntu
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: argument --error-logfile/--log-file: expected one argument
我正在关注本教程-https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html
有人可以帮忙吗?
答案 0 :(得分:0)
实际上未在配置中定义日志文件-
#!/bin/bash
NAME="django_app" # Name of the application
DJANGODIR=/home/ubuntu/bekaim_pre_registration # Django project directory
SOCKFILE=/home/ubuntu/django_env/run/gunicorn.sock # we will communicte using this unix socket
USER=ubuntu # the user to run as
GROUP=ubuntu # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bekaim_pre_registration.settings # which settings file should Django use
DJANGO_WSGI_MODULE=bekaim_pre_registration.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/ubuntu/django_env/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file=-