Django Gunicorn wsgi

前端 未结 2 1678
情歌与酒
情歌与酒 2021-01-14 11:18

Hi I am trying to integrate my django 1.4.1 app with Gunicorn 0.14.6. I start gunicorn server from command line like so -

gunicorn -c /home/code/gunicorn_co         


        
相关标签:
2条回答
  • 2021-01-14 12:08

    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

    0 讨论(0)
  • 2021-01-14 12:13

    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
    
    0 讨论(0)
提交回复
热议问题