gpt4 book ai didi

python - 在 virtualenv 中找不到 Gunicorn

转载 作者:行者123 更新时间:2023-12-02 06:59:27 25 4
gpt4 key购买 nike

我正在部署 django 应用程序,当我手动运行它时它工作正常。我正在尝试使用主管,但是当我运行 sudo Supervisorctl status botApp 时,日志文件显示:

Starting botApp as ubuntu
/home/ubuntu/gunicorn_start.bash: line 28: exec: gunicorn: not found

我的gunicorn_start.bash如下:

#!/bin/bash

NAME="botApp" # Name of the application
DJANGODIR=/home/ubuntu/chimpy # 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=botApp.settings # which settings file should Django use
DJANGO_WSGI_MODULE=botApp.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=-

我的/etc/supervisor/conf.d/botApp.conf 中的配置文件是:

[program:botApp]
command = /home/ubuntu/gunicorn_start.bash;
user = ubuntu;
stdout_logfile = /home/ubuntu/logs/gunicorn_supervisor.log;
redirect_stderr = true;
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8;

我的 Gunicorn bash 有问题吗?非常感谢

最佳答案

检查虚拟环境是否处于事件状态。只需编写简单的脚本

#!bin/bash

source /var/www/html/project_env/bin/activate

然后运行命令-> sudo bash file_name.sh

如果您没有收到任何错误,则表示 venv 已激活

注意 - 您不会在终端或 shell 上获得任何 venv 激活标记。

关于python - 在 virtualenv 中找不到 Gunicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52097099/

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