Django Gunicorn wsgi

試著忘記壹切 提交于 2019-12-01 09:24:20

Your django_settings is incorrect. django_settings should be in the form of a python module import that is importable from the Python path you set. So

pythonpath = '/home/code/po'
django_settings = 'po.settings'

To elaborate a bit more, application is the default variable (which should be a WSGI application object) gunicorn will try and import from the Python module that you supply.

So to think about it another way. Say you were trying to run a simple Flask wsgi appication. The actual WSGI app was defined as application and lived inside /home/code/views.py. Then the following would manually start serving it with gunicorn

export PYTHONPATH=/home/code
gunicorn -w 2 views:application

So the variable application inside the views module. You can read about how Django provides you with the application object.

It might be that you need to point gunicorn at the po.wsgi module itself. It's a little hard to tell from the information provided so far. If that module was created properly it should contain a variable called application

Check if another package you have installed already contains a file called wsgi.py. (gevent does.) If so, likely the wrong wsgi.py file is being loaded. Try renaming your wsgi.py file to something else (e.g. app_wsgi.py) and add run your app using

gunicorn -c /home/code/gunicorn_config.py app_wsgi
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!