如何设置 gunicorn 脚本 (django)
How to set up a gunicorn script (django)
我使用 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
我使用 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