Why is Procfile not recognised by Heroku? - flask

I'm trying to deploy a flask app to heroku, but I keep on getting the error:
Scaling dynos... ! ▸ Couldn't find that process type (web).
whenever I try to run heroku ps:scale web=1.
However, when I run heroku ps:scale, it tells me that I need to Upload a Procfile to add process types.
I do have a Procfile located in my root directory, and it is capitalised and doesn't have any file extensions. I have tried deleting and recreating the Procfile, but this hasn't produced any results.
How do I get Heroku to recognise my Procfile?
Here is what I've been trying to do:
ubuntu terminal

I had to create a new git repo and heroku app, and copy the code over for it to work.

Related

Error during deploying django app in Heroku

I am trying to deploy a Django application to Heroku. When I followed the documentation and tried the command git push heroku master, I am getting an error: failed to push some refs to 'https://git.heroku.com/sleepy-eyrie-25993.git'. I searched online and tried to use git pull. But it didn't work. I also tried using git push -f heroku master, but still getting the same error. Is there any other way to do it? I followed this doc
https://devcenter.heroku.com/articles/python-support.
Tried using the heroku dashboard, but it is giving the same error
Building on the Heroku-18 stack ! No default language could be detected for this app. HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically. See https://devcenter.heroku.com/articles/buildpacks ! Push failed
You can also deploy from your application dashboard on Heroku
Heroku deployment requires requirements.txt in the root of the repository.
Also, to run a Django app - it requires file Procfile
Sample content:
web: gunicorn your_app_name.wsgi:application --log-file -
You can also try to specify buildpack manually by executing:
heroku buildpacks:set heroku/python
Then if there are additional errors starting - they will be more specific
Also settings.py of your Django application should contain the following:
import django_heroku
django_heroku.settings(locals())
For more details, please refer Here

Hide Django's staticfiles from GitHub stats

To understand what I'm talking about, I call GitHub stat this line:
I have my Django project on GitHub repository and, I use Heroku to deploy this project. To deploy my project to Heroku, I need first to run python manage.py collectstatic that will generate a lot of CSS and JS like on screenshot above.
I want to hide this folder not ignore, because Heroku needs it to work properly.
UPD 1:
So, I created new branch called debug. debug branch is identical with master, but, without staticfiles folder. And when i start Heroku with this branch, as i said, it gives me an 500 Server Error. Ofcourse, I runned python manage.py collectstatic before start.
UPD 2:
After restarting all Heroku dynos (heroku ps:restart in CLI), all works fine without pre compiled staticfiles.
This:
To deploy my project to Heroku, I need first to run python manage.py collectstatic
is not true. Heroku will run collectstatic for you when you deploy. You do not need to run it before deploying, and you definitely do not need to add the destination directory to git.

How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?

I'm trying to get deploy a simple django app, and have successfully pushed my git repository to Heroku. However, when I attempt to run:
heroku ps:scale web=1
I get the following error
Scaling dynos... failed
! Couldn't find that formation.
Any thoughts as to what the problem might be? The contents of the Procfile (below) are correct to the best of my knowledge.
web: gunicorn my_app_name.wsgi
To state the obvious: another way to encounter this issue is if you're working on a new app, and you try running heroku ps:scale web=1 before you've actually done a git push heroku master. There is no Procfile on the Heroku server in that case, because there aren't any files at all. :D
Ensure that your Procfile has no extension.
To create a file with no extension on Windows, you can use the command notepad Procfile. from the command line.
To add yet another reason this can happen, my Procfile contained
web:gunicorn
but it should be:
web: gunicorn
As far as I can tell from all of these answers, if you run into this problem, it is very likely related to Procfile.
for those interested, I had the same problem to add a worker. to do so you need to add this line to your procfile : worker: python worker.py
For others experiencing this same issue, make sure Procfile is not ignored in git.
Delete your Procfile. Then git status. If don't see anything mentioning Procfile, you need to find remove the entry from local or global .gitignore.
I faced a similar issue while working on windows(haven't tested on other operating systems)and this worked fine for me.
Initially, I have created a file name procfile and pushed it to heroku. But, heroku expects the Procfile declaration. It is case sensitive. Hence, we should be careful while typing the filename also.
Even after changing the name to Procfile git didnt notice changes(maybe git is case-insensitive just like windows). Hence, I had to delete the file completly and had to create a new one with Procfile as the name of the file.
I had the same problem because I missed git add and git commit the file named Procfile .
You should try to use the command git status and review whether the Procfile is included.
When pushing to Heroku you must come up with something like shown in the Picture. If not your procfile has an Error.
The Procfile looks like this for my Flask app
web: gunicorn app:app
In my php project I can use
$ heroku ps:scale web=1
at the heroku directory "php-getting-started" (https://devcenter.heroku.com/articles/getting-started-with-php#prepare-the-app).
So I'm try to do this in my original application, so I tried to do again in Heroku Repository and it's work.
(sorry about the english, hehe)
I got the same problme,
1) I also configured ProcFile
but the problem still available
So used this
Remove the existing buildpacks with heroku buildpacks:clear and add them again in the right order using the heroku buildpacks:add with the --index option, making sure that the language buildpack is the last in the list
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
Problem solved
I had a similar problem and tried the following:
Made sure Procfile does not have any extension
Procfile is spelled exactly as 'Procfile'
At the end of the day just realized that my Procfile was in my app directory. It should be on the root/project directory.

Images in public folder are not updated while deploying on Heroku

I have a strange issue while deploying to Heroku.
Since a few days ago, it seems that when I deploy, my modified images are not updated on Heroku.
The process is this one :
I modify the image (like the size)
I commit the modification
I push on Heroku
I try to load the image -> not updated
I run heroku run bash to witness the file on public/ folder -> not updated, still with the old size
As with this answer, git ls-files public -o shows nothing out of place
I checked on github, my file is well updated in my repo -> not a git problem
I duplicated an image an named it diferently : it is loaded on the repo. I then deleted it : still on the repo.
So I guess it's a cache issue. Therefore I tried this answer to purge the assetscache... with no luck.
Run the command:
heroku run rake assets:clean
If it doesn't work, then run the following command:
heroku run rake assets:precompile

How to link a folder with an existing Heroku app with mercurial

I have an existing Django app on Bitbucket and I'm able to deploy to Heroku whith hg-git. Whenever i want to run some heroku command inside my app folder i get the following errors:
$ heroku ps
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
$ heroku logs
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
etc.
Current workaround is to specify the app name: heroku ps --app <app name> but i'm looking for a way to link my repository name to the remote Heroku app name like how it's done using git.
I'm not in a position to move my app to github for now.
I'd suggest trying Hg-Git's "intree" configuration option. Set that by adding the following to your hgrc:
[git]
intree = True
With that set, the Git repository used internally by Hg-Git will be stored as a ".git" directory within the working copy, rather than nested within the ".hg" directory.
Heroku will then see this repository's config. Add a remote as suggested in the other answer (quoted below), and you should be all set.
git remote add heroku git#heroku.com:<app-name>.git
For now, the best documentation of Hg-Git configuration options that I've found is the README displayed on the project's Bitbucket page: https://bitbucket.org/durin42/hg-git
Considering heroku is looking at the .git/config file to get the app name, just do the following inside your local repository:
git init
git remote add heroku git#heroku.com:<app-name>.git
In order not to mess your repository, you'll also add the following lines to .hgignore:
#Git setup
.git/**
Now, usual heroku commands no more ask for the default app name.