How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku? How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku? python python

How can I modify Procfile to run Gunicorn process in a non-standard folder on Heroku?


Try:

web: gunicorn --pythonpath app app.wsgi


As @Graham Dumpleton stated in his answer, the OP's problem could be solved by modifying his Procfile to the following:

web: gunicorn --pythonpath app app.wsgi

Why this works:

  • Remember, that the Procfile is simply used by Heroku to start processes. In this case, gunicorn processes.
  • Gunicorn's --pythonpath argument allows you to dynamically attach a directory to the list of directories that the Python runtime searches for when do module look-ups.
  • By adding --pythonpath app to the gunicorn command, the interpreter was basically told 'look inside of the app directory for a package (also) called app which contains a module called wsgi.`

The generic names of the folders in the OP's question can obscure the syntax of the command, which is as follows:gunicorn --pythonpath <directory_containing_package> <package>.<module>

More Info:
Gunicorn Documentation


I made a ugly hack for getting this working. So I'm going to post my answer, but I hope you guys can come up with a better solution

Procfile

web: sh ./app/run.sh

app_project/app/run.sh

#!/bin/bashcd appgunicorn app.wsgi