我们在生产中使用gunicorn_django部署了一个应用程序。我注意到不再推荐它。我想知道为什么不推荐这样做,以及我们是否需要迁移到更新的方式。
来自https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/gunicorn/
If you run Django 1.4 or newer, it’s highly recommended to simply run your application with the WSGI interface using the gunicorn command.
最佳答案
gunicorn_django
的重要部分 wsgi.py
已集成到 Django 本身中。
Starting with Django 1.4, your project will already have a
wsgi.py
, which can be used with any wsgi server (of which there are many, gunicorn being just one).Essentially the old Django integration for
gunicorn
was just a convenience to get you up and running faster, but it's no longer necessary because all Django projects now havewsgi.py
.
更新
首先,在Gunicorn 18.0 gunicorn_django
became deprecated .
其次,自从第一次写这个答案以来,我个人遇到了一些晦涩的错误
特定于 gunicorn_django
与 --settings
命令行参数(gunicorn
命令和 ./manage.py runserver
结合使用) > 工作正常)。
即,模糊的导入错误 application.some_model: 'field' 与模型 another_application.AnotherModel 有关系,该模型要么尚未安装,要么是抽象的。
所以,不,我不建议您在新项目中使用 gunicorn_django
。
关于django - 为什么不再推荐gunicorn_django?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16369354/