django - gunicorn:错误:参数--error-logfile/--log-file:预期一个参数
问题描述
我正在尝试制作一个 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
任何人都可以帮忙吗?
解决方案
实际上日志文件没有在配置中定义 -
#!/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=-
推荐阅读
- javascript - 如何使用/引用在同一个 json 模式中生成的字段值
- spring - 未找到多部分边界
- java - 为什么我不能在循环中编写返回语句?
- mysql - 具有延迟模式和表结构的新升级应用程序中的 mysql 数据迁移工具
- vba - Access VBA 读取当前记录集位置?
- node.js - Angular 使用错误的 URL 使用 NodeJS 查询 MongoDB
- python - 如何在熊猫的groupby中找到总数的百分比
- python - 如何处理小数和千位分隔符的逗号
- gradle - 哪个 Maven BOM 确定 Gradle 5 中依赖项的版本?
- json - 使用来自 s3 的 Python3.x 快速处理 json