Configuring gunicorn for Django on Heroku

后端 未结 4 991
梦毁少年i
梦毁少年i 2021-01-05 19:24

I\'m trying to setup a test Django project on Heroku. Following the advice here and in the Heroku Getting Started I\'m trying to use gunicorn instead of the Dj

相关标签:
4条回答
  • 2021-01-05 19:31

    I had this issue and landed up having to point directly to the python path and then set the settings reference.

    In the end my Procfile looks like this:

    web: gunicorn_django --pythonpath=/app/project --settings=settings
    

    I had to run heroku run which showed the env variables and that's where I was able to find the /app which I prepended to my project name.

    0 讨论(0)
  • 2021-01-05 19:31

    Do you have a requirements.txt in the root folder (containing the word django), as well as a settings.py? Those appear to the be the requirements for Django app detection, as documented here.

    0 讨论(0)
  • 2021-01-05 19:36

    I had the same exact issue that you are having. The way I was able to finally get it working was to use the django app gunicorn.

    I added gunicorn to the django settings.py

    'gunicorn',
    

    I then used this as my web entry in my Procfile.

    web: python manage.py run_gunicorn -b 0.0.0.0:\$PORT -w 9 -k gevent --max-requests 250 --preload
    

    You may have to alter you .manage.py if you use a different directory structure then I did. My app was in /app, and my python path was also /app.

    0 讨论(0)
  • 2021-01-05 19:45

    I have just run into this same issue. In the procfile you copied from the Heroku guide, change hellodjango.wsgi to yourproject.wsgi

    Looks like we all fall victim to blindly copy-pasting now and then, but in your (and my) defense, it looks like there's no *.wsgi file that's actually being opened, it's just how you signal to gunicorn that you want it to run your django project.

    0 讨论(0)
提交回复
热议问题