【发布时间】:2015-03-25 17:24:43
【问题描述】:
当我部署我的 Django 站点时,我对 wsgi.py 文件以及它在本地使用与在生产中使用 Gunicorn 的方式有点困惑。
本地我有这个文件结构。
demo/
__init__.py
settings.py
urls.py
wsgi.py
manage.py
Settings.py 有如下设置...WSGI_APPLICATION = 'demo.wsgi.application'
但是,一旦我部署了在 Gunicorn 上运行的应用程序,我收到一条错误消息,说它找不到 wsgi.py 文件,为了让它工作,我必须像这样再次创建文件...
demo/
__init__.py
settings.py
urls.py
wsgi.py
manage.py
wsgi.py
这现在有效,但它向我暗示 Gunicorn 忽略了 Django 设置文件 demo/settings.py 中的 WSGI_APPLICATION 设置,对吧?如果是这样,Gunicorn 在哪里获得对 wsgi.py 文件位置的自己的引用以及本地有什么不同?
这是我的 Gunicorn 设置以防万一……
[program:gunicorn_process]
command=gunicorn wsgi:application -c /srv/test/gunicorn.conf.py
directory=/srv/test
user=root
autostart=true
autorestart=true
redirect_stderr=true
gunicorn.conf.py
bind = "127.0.0.1:8001"
workers = 3
worker_class = 'gevent'
【问题讨论】:
标签: python django wsgi gunicorn