Django WSGI 和 Gunicorn

2024-01-11

这可能是一个非常愚蠢的问题;我正在尝试使用 Gunicorn 部署 Django 应用程序。但是,我刚刚创建了 wsgi.py,如下所示(wsgi.py 位于我的根项目文件夹中):

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)

现在我跑了:

python manage.py run_gunicorn

Gunicorn 会自动获取这个 wsgi.py 吗?这是如何运作的? (不确定 wsgi 在做什么)。或者我需要指定一些东西吗?


如果 Django 设置模块的 INSTALLED_APPS 中列出了 Gunicorn,则命令为:

python manage.py run_gunicorn

不是你发出的命令。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Django WSGI 和 Gunicorn 的相关文章

随机推荐