Deploying Django on Heroku? - python

I am trying to host a Python\Django app on Heroku. I followed the guide on heroku website but when I execute the line "heroku ps:scale web:1" it comes back the following message:
No process types on ⬢ salty-brushlands-45215.
▸ Upload a Procfile to add process types.
▸ https://devcenter.heroku.com/articles/procfile
I already tryed to commit a Procfile into my project (searching for a solution) but I don't know if requires any configuration inside it. Help please!

Your Procfile should contain this,
web: gunicorn your_project.wsgi
web defines the type of your application
gunicorn is a wsgi server

1.Create .txt file.
2.add this raw to your file:
worker: python main.py
3.save file and delete file extension (.txt)
4.add Procfile to master folder
5.deploy

Related

Flask app can't seem to find relative parent package at Heroku

I'm trying to deploy a Flask app to Heroku.
When I run it locally, it works fine.
But when I deploy it to Heroku and start the dyno, it crashes.
It seem to have a problem with the relative parent package:
The project structure is as follows:
My Procfile is as follows:
web: gunicorn app:app --log-file=-
And this is the line it crashes at:
Why it fails to see that parent package?
Thanks in advance!

Can't get heroku procfile

I'm trying to build up a deep-learning-based facebook chatbot (using Python). I'm trying to deploy it on Heroku firstly, but as I'm using the command web: gunicorn echoserver:app the terminal says web: command not found. Howevere, I've installed gunicorn already.
This is because you are typing web:, which is not a command line interface (CLI) command.
If you've installed gunicorn, then the command (from the CLI) is gunicorn. Something like, for instance
gunicorn echoserver:app
I suppose it's also possible that you have a Windows machine. gunicorn does not work on Windows, so you would need to use something like waitress. With waitress, you would type web: on a Windows machine, so that it would be something like
web: waitress-serve echoserver:app
Note that the procfile is literally a file you place in your repository. The contents of the procfile should contain the command you want Heroku to run to start your server.
So in the root directory of your repo, you should have a Procfile (named exactly that with no file extension) with the following contents:
web: gunicorn echoserver:app
The first part (web:) is just used to tell Heroku which dyno to run the second part (the command) on. So Heroku will only run the command on web dynos and not on background dynos.
More info here: https://devcenter.heroku.com/articles/procfile

Heroku not reading requirement.txt file

I am trying to deploy my python flask app to heroku but it keeps crashing and complaining about bash: gunicorn: command not found. I have my requirement.txt file in the root folder where my Procfile is also located. My python code is located in src/server/
Procfile contains: web: gunicorn --pythonpath src/server/ route:app --preload
I have gunicorn in my requirements file:
Is there something i'm missing?
gunicorn==19.8.1
Flask==0.12.2
Flask-Cache==0.13.1
Flask-Cors==3.0.2
Flask-MongoAlchemy==0.5.1
flask-mongoengine==0.9.5
Flask-PyMongo==0.5.2
Flask-WTF==0.14.2
gevent==1.2.1
greenlet==0.4.12
pymongo==3.6.1
folder structure;
I faced a similar problem with my app. I just reset all my requirements by sending in an empty requirements.txt file. Then built my app. Then sent the original file. I don't understand why, but it worked.
I am also having a similar problem like this on Heroku. I created an IDENTICAL new project and magically it works. Heroku has some bug related to ignoring requirements.txt
I fixed it by creating a new environment in Heroku. The previous environment seems not to be reading the requirement.txt file, I couldn't figure why.

Heroku local invalid port number or address:port pair - deploying django app

I have this ProcFile file following this guidelines for django app deployment on section Build your app and run it locally in order to test it locally you have to run this command.
web: python manage.py runserver 0.0.0.0:$PORT
Then running heroku local or heroku local web got me into this error:
CommandError: "0.0.0.0:$PORT" is not a valid port number or address:port pair.
You must not use runserver in production. Use gunicorn as the docs and comments suggest.
For local:
If you follow this official heroku tutorial and you are running it on Window platform locally, instead of $PORT, you have to use %PORT% at your Procfile.windows:
web: python manage.py runserver 0.0.0.0:%PORT%
since window does not interpret $PORT expression which only applicable in Unix shells.
If one using waitress as WSGI and wanna run it locally on Window platform, your Procfile should looks like this:
web: waitress-serve --port=%PORT% wsgi:your_app
For real online deployment:
simply include gunicorn package in requirementx.txt and your Procfile should be in this way:
web: gunicorn wsgi:your_app
If you are using waitress, you need to change back to $PORT, and set it in this way instead of fixed port number since Heroku assigns port to your app dynamically. Also, do make sure the host is set to 0.0.0.0 so your app is available externally.
For a django project in heroku you must have a Procfile like this:
web: gunicorn yourapp.wsgi
The filename must be Procfile, and not ProcFile
If you want to run into development you can either $ python manage.py runserver in your shell (heroku independent) or run $ heroku local with a valid production Procfile

Heroku No such process type web defined in procfile

When i'm runing heroku ps:scale web=1, I'm getting below error.
Scaling dynos... failed
No such process type web defined in Procfile.
My Procfile contains below code.
worker: python vot.py
I also did heroku run bash and the Procfile is there and file name is also correct.
How could i solve this ?
Your heroku command has "web=1" but your Procfile has "worker". Try:
heroku ps:scale worker=1
I dont see you define single process type "web" in your procfile.
Follow on this heroku procfile and define python procfile
:
web: gunicorn gettingstarted.wsgi --log-file -
This declares a single process type, web, and the command needed to run it. The name web is important here. It declares that this process type will be attached to the HTTP routing stack of Heroku, and receive web traffic when deployed.
Procfiles can contain additional process types.
worker: bundle exec rake jobs:work

Categories

Resources