Skip to content Skip to sidebar Skip to footer

Heroku Deployment Using Django And Gunicorn: Missing Gunicorn_django File Or Dir

This blog advises to put the following in my Procfile. web: python myproject_django/manage.py collectstatic --noinput; bin/gunicorn_django --workers=4 --bind=0.0.0.0:$PORT myproje

Solution 1:

The blog post you refers to dates back to november 2011 when the virtualenv was installed in /app. The new style virtualenv commit moved the virtual env from /app to /app/.heroku/venv.

This explains your initial error, /app/.heroku/venv/bin/gunicorn_django should exist.

This is bad practice:

You won't succeed to durably collect static files by collecting them after the push. Read the doc, especially the ephemeral filesystem part: collectstatic and open run in two different dynos, what's collected in the first won't be available to the second thus explaining the inconsistencies you pointed in your edit.

It only works if you collect files and launch the server in the same [web] process but then it would recollect all static files every time the dyno is restarted. Just feels like bad design.

Either:

  • collect your static files before pushing to heroku
  • use another solution (like S3 even if the purpose of the blog post was not to use it)

Anyways, serving static assets with an elegant and efficient workflow ain't easy.

IMHO, better to stick with one command per process in Procfile, I'll suggest you start scripting your deploys if you want to chain commands.


Solution 2:

make sure you have gunicorn as an installed app in settings.py.

and try running:

python my_project/manage.py run_gunicorn <options>


Post a Comment for "Heroku Deployment Using Django And Gunicorn: Missing Gunicorn_django File Or Dir"