gpt4 book ai didi

django - gunicorn 找不到 django wsgi 模块

转载 作者:行者123 更新时间:2023-12-04 18:07:51 25 4
gpt4 key购买 nike

我正在尝试按照此 blog 为 Django 设置 gunicorn .我创建了 gunicorn_start脚本并授予它权限:

$ sudo chown -R hello:users /webapps/hello_django
$ sudo chmod -R g+w /webapps/hello_django

使其可执行:
$ sudo chmod u+x bin/gunicorn_start

但是当我运行这个命令时:
advenio@advenio-VirtualBox:~$ sudo su - hello
$ bin/gunicorn_start

它给了我一个错误:
advenio@advenio-VirtualBox:~$ sudo su - hello
$ bin/gunicorn_start
Starting hello_app as hello
bin/gunicorn_start: line 26: /webapps/hello_django/hello/../bin/gunicorn: No such file or directory

这是 gunicorn_start脚本:
#!/bin/bash

NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
source ../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 ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE

最佳答案

好的,我不得不删除

../bin


exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \

现在,它只是:
exec gunicorn ${DJANGO_WSGI_MODULE}:application \

希望这会帮助像我这样的人。

关于django - gunicorn 找不到 django wsgi 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22451750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com