How to Modify Procfile to Run Gunicorn Process in a Non-Standard Folder on Heroku

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

change

web: gunicorn --pythonpath application.george_paintings george_paintings.wsgi

to

web: gunicorn --pythonpath application.george_paintings.george_paintings.wsgi

You had a blank space in between the folder names.

Deploying a Django application to Heroku - No module named 'django_project.wsgi

With Procfile at the root directory (that is, one level above manage.py), I've changed its content to the following:

web: gunicorn --pythonpath django_project django_project.wsgi --log-file -

As per this answer.

Here's my project structure now, just in case it wasn't clear where Procfile is located:

Sample Image

Now everything works as it should.

I'm marking this question as solved.

heroku procfile problem : ModuleNotFoundError: No module named 'myApp.wsgi'

djangoherokuapp
|-- tabele/
| |--- __init_-.py
| |--- settings.py
| |--- urls.py
| |--- wsgi.py
|----- manage.py
|------Procfile ⬅⬅⬅
|------requirements.txt
|----- app/
| |--- admin.py
| |--- apps.py
| |--- __init__.py
| |--- models.py
| |--- tests.py
| |--- views.py

  • Add a Procfile in the project root directory to define process types
    and explicitly declare what command should be executed to start your
    app
    .

  • Open the Procfile and add the line below:

    web: gunicorn tabele.wsgi --log-file -

  • --log-file - means "log to stdout". The --log-file flag lets you
    set a path to a log file, and - means "stdout" (in this context).

Or try with:

 web: gunicorn tabele.wsgi

ModuleNotFound error trying to open Django app in Heroku- issue with gunicorn setup?

#----------------------------Install packages---------------------------- 
1)pip install django-heroku
2)pip install whitenoise

#-----------------------------setting.py----------------------------------#
1)INSTALLED_APPS = [
...,
'django_heroku',
]

2)MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',

]

3)STATICFILES_STORAGE =
'whitenoise.storage.CompressedManifestStaticFilesStorage'

4)STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)

django_heroku.settings(locals())

#-----------------------urls.py---------------------------------------#
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
...,
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

#------------------Procfile create in Root DIR-----------------#
paste in (web: gunicorn projectname.wsgi)

#--------------create requirements.txt---------------------------#

pip freeze > requirements.txt

# runtime.txt create in Root DIR
paste in (your python version for ex.python-3.8.5)

#---------then commands in terminal-------------------------#

heroku login
heroku create YOUR_APP_NAME

##for Clone the repository.......
git init
heroku git:clone -a YOUR_APP_NAME

## for Deploy your changes......
git init
git add .
git commit - m "initial"
git push heroku master

## then

heroku run python manage.py migrate
heroku run python manage.py createsuperuser


Related Topics



Leave a reply



Submit