gpt4 book ai didi

python - 如何设置gunicorn脚本(django)

转载 作者:太空宇宙 更新时间:2023-11-03 17:25:50 25 4
gpt4 key购买 nike

我使用gunicorn来启动我的django应用程序。为此,我通常进入 manage.py 文件所在的目录,然后使用以下命令:

gunicorn --env DJANGO_SETTINGS_MODULE=app.my_settings app.wsgi --workers=2

我从 official documentation 得到的(它使用不同的设置文件)

现在,我想编写一个脚本来完成我发现的 here 的任务:

#!/bin/sh

GUNICORN=/usr/local/bin/gunicorn
ROOT=/path/to/folder/with/manage.py
PID=/var/run/gunicorn.pid

#APP=main:application

if [ -f $PID ]; then rm $PID; fi

cd $ROOT
exec $GUNICORN -c $ROOT/ gunicorn --env DJANGO_SETTINGS_MODULE=app.my_settings app.wsgi --pid=$PID #$APP

但是我明白了

usage: gunicorn [OPTIONS] [APP_MODULE]

gunicorn: error: unrecognized arguments: app.wsgi

当我执行它时。知道如何编写才能使其正常工作吗?

还有,PID 是什么?

谢谢!

最佳答案

好吧,这很简单,只需使用 (sudo nano Gunicorn.sh) 创建一个文件

cd /path/to/folder/with/manage.py/
exec gunicorn --env DJANGO_SETTINGS_MODULE=app.my_settings app.wsgi

然后执行

./gunicorn.sh

关于python - 如何设置gunicorn脚本(django),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32571893/

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