garethbjohnson / gutendex

Web API for Project Gutenberg ebook metadata
https://gutendex.com
MIT License
236 stars 48 forks source link

Deploy gutendex on heroku.com #19

Closed phr85 closed 3 years ago

phr85 commented 3 years ago

Hello

I try to deploy gutendex on heroku.com. But I don't know exactly how to do it. What I did so far:

Create "Procfile" file: release: pip install gunicorn && python manage.py migrate && python manage.py updatecatalog && python manage.py collectstatic web: gunicorn gutendex.wsgi

Catalog (DB) is now generated. But somehow Server always crash on start up:

Screenshot 2021-10-22 at 15 21 08

Maybe someone can help me?

garethbjohnson commented 3 years ago

Hello Philippe

I just fixed a bug that I found in Gutendex's updatecatalog script. Could you pull the latest code, try again, and let me know if it works now?

phr85 commented 3 years ago

Hello @garethbjohnson Thank you for fix. Catalog is generating well.

But somehow my run config script is somehow not working:

Procfile: release: pip install gunicorn && python manage.py migrate && python manage.py updatecatalog && python manage.py collectstatic web: gunicorn gutendex.wsgi

Screenshot 2021-10-28 at 10 47 41 Screenshot 2021-10-28 at 10 47 50

garethbjohnson commented 3 years ago

In your release command, it looks like the collectstatic part fails because, by default, it requires the user to type "yes" to confirm. To fix this, you can skip the user input requirement by adding --no-input to the collectstatic part of the command like this: python manage.py collectstatic --no-input

I think your web command is failing somewhere because it tries to run manage.py runserver instead of python manage.py runserver or ./manage.py runserver. However, I don't see that in your Procfile, so I don't know where that faulty command comes from. Maybe you just need to put the web: command on its own line? I was able to get Gutendex running on Heroku with this Procfile:

release: pip install gunicorn && pip install django-heroku && python manage.py migrate && python manage.py updatecatalog && python manage.py collectstatic --no-input
web: gunicorn gutendex.wsgi
phr85 commented 3 years ago

@garethbjohnson Thank you very much for helping me!

I tried but somehow it still not working: Screenshot 2021-10-29 at 13 09 39

Which python version do you use in your "runtime.txt"? I use "python-3.6.15".

Screenshot 2021-10-29 at 13 10 59

I'm not sure what MEDIA_ROOT and STATIC_ROOT has to be on Heroku. "/app/static/"?

garethbjohnson commented 3 years ago

I did not add a "runtime.txt", but it seems to use Python 3.9.7. (I also had to update the version of psycopg2 to 2.9.1 in "requirements.txt", but I don't know if that's related to the Python version.)

For STATIC_ROOT, I used "/var/www/gutendex/static", but I think the django_heroku package overrides this anyway, and a blank value seems to work for me, too. If updating the Python and psycopg2 versions doesn't work, try making sure in "gutendex/settings.py" you are importing django_heroku at the top and have this at the bottom: django_heroku.settings(locals())

phr85 commented 3 years ago

Hello @garethbjohnson Thank you for your help. I did exactly what you advice me. It run through processes but in end somehow server not really run (crashing). Any idea what else I could try?

Screenshot 2021-10-30 at 11 02 16 Screenshot 2021-10-30 at 11 02 06 Screenshot 2021-10-30 at 11 01 58

garethbjohnson commented 3 years ago

Ah, I think you now just need to add the line gunicorn==20.1.0 to your "requirements.txt". (Also make sure you have django-heroku==0.3.1.)

phr85 commented 3 years ago

@garethbjohnson YES! Thank you very much, now is working!