I'm stuck at this simple task.
I have some configuration files that should be ignored by Git. But after commit to Heroku, I always get Application Error.
If I ignore those files then I have no way to get around the situation, but adding them to Git is definitely not a good idea.
Is there any way to ssh into Heroku server, I found no instructions on Heroku?
You can run a bash shell for your heroku app by doing this. Note that it will spin up another dyno, which will shut down when you exit the shell:
heroku run bash
Related
I'm deploying an app to Heroku, which means pushing to their git repo. When do git push heroku master (or the equivalent remote alias) I get this warning:
WARNING: You're about to push to master, is that what you intended? [y|n]
Which is kinda annoying but not a big deal. However, I'm now scripting deployments so I don't want to have interact with the script - how I do get my bash script to answer y automatically?
I tried doing yes | git push heroku master but that doesn't work.
Agree with #bk2204, I would check if a git hook is being used that you are unaware of.
Git hooks are not version controlled, so make sure you are searching for this at the machine where you get this error.
The git hook may live elsewhere other than the .git directory. Check if git config core.hooksPath is set and if so, it will point to the directory where your git hook is.
The hook file that you are looking for will most likely have the name pre-push. The solution in this case is to remove or rename this hook file, and git won't run it before push.
Nope, no such file
And yet, this is exactly what a .git/hooks/pre-push would do, like this one.
To rule that out, activate (with your local Git 2.25+) trace2.
That will allow you to see what is used on the client side (your PC) by Git:
git config --global trace2.normalTarget ~/log.normal
Try your push, type 'n' (to abort), and check ~/log.normal for clues.
Just another way to solve the problem of automating responses to the prompts. You can use expect to take care of interactive warnings/ prompts.
After writing the deployment script deploy.sh, you can write a expect script and spawn the deploy script in it, for response to
WARNING: You're about to push to master, is that what you intended? [y|n]
message, you can send 'y' from expect.
The following snippet can be taken as example
#!/usr/bin/expect -f
spawn bash ./deploy.sh
expect "WARNING: You're about to push to master, is that what you intended? [y|n]\r"
send -- "y\r"
I'm trying to run commands for my heroku app in my console, but it keeps telling me "Couldn't find that app." even though when I run heroku apps in my console it tells me I have one app called worldofwarcraft-api
So heroku recognizes my app in the apps list, but I can't run any commands to access it. The line I want to run is
heroku ps:scale web=1 --app worldofwarcraft-api
I'm trying to troubleshoot why my API returns a 503 when I try to make a GET request to it. This is the fix the heroku faq told me to try, but it's just telling me it can't find my app.
I'm wondering if it has something to do with the fact that I deployed my API from github, rather than running the heroku setup in my console. I don't know if that would effect my ability to run heroku commands on the app in my local console.
Apologies if my formatting is off a bit. I'm still getting used to this site.
In my case, someone renamed GitHub repo and I tried to find Heroku app with new GitHub name
It helps me
heroku apps
heroku git:remote -a YOUR_APP
Solved it. Just sharing for future searches.
The issue was fixed by running git init and then heroku git:remote -a worldofwarcraft-api in my command line while inside my repositories folder. This initialized git in the repo and then set the heroku git remote to that repository.
Hopefully, this helps anyone else who had a similar issue.
Just an easy way to solve this issue:
1st: Add the command into your terminal: $ heroku apps
If you already logged into your heroku account from your terminal, all your apps will appear as a list like this:
your-project-name-1
your-project-name-2
your-project-name-3
your-project-name-4
2nd: Then chose which one you are needing to connect with the following command:
$ heroku git:remote -a your-project-name-2
If you've done the connection properly you'll receive the following output:
set git remote heroku to https://git.heroku.com/your-project-name-2.git
For my case, I was renaming my github repository.
You can find it in your repository settings then just rename it, it appears in the first place.
Then you can continue with git init again to re-initiate your existing git repository and then set your heroku remote with your heroku apps new name heroku git:remote -a YOUR_APP_NAME
If the app belongs to a team that you participate in, you have to specify the team option in the commands to see the app:
E.g:
heroku apps -t <team name>
or
heroku ps:scale web=1 --app worldofwarcraft-api -t <team name>
Use case is to bust the cache.
What is a good way to run given code (or rake task) whenever a Ruby Heroku app is restarted (or deployed)?
There's no way to do this via the Heroku API far as I know. The Heroku Platform API doesn't support this.
What you can do (if you're fast, however!) is listen for a SIGTERM message in your code (that's what Heroku sends to your application process when it attempts to restart it) -- you can then fire off your script quickly.
Here's more information on SIGTERM on Heroku: https://devcenter.heroku.com/articles/dynos#graceful-shutdown-with-sigterm
If you're using some sort of CI, you can probably configure it there. Heres how to do it with CircleCI:
deployment:
production:
branch: production
commands:
- git push git#heroku.com:foo-bar-123.git $CIRCLE_SHA1:master
- heroku run rake <your task> --app <your app name>
If you're not using a CI you can still whip together a script that first does the git push to Heroku and then executes your cache busting task through heroku run (the app's bin/ folder would be an obvious place to put it).
Note: you can also use heroku run:detached, which will send output to your logs instead of stdout.
You can use "release" feature that allows you to run any command before a new release is deployed. https://devcenter.heroku.com/articles/release-phase
Define the command that should be run in your Procfile.
release: rake db:migrate
From documentation:
The release command is run immediately after a release is created, but before the release is deployed to the app’s dyno formation. That means it will be run after an event that creates a new release.
I had a case where a push to heroku failed because of a database issue. I fixed it, but the only way I know to deploy is via "git push heroku master". Since I didn't commit anything, it won't push a new deployment. The only way I can get it to deploy to make some minor change and then do it. Is there a way to force a deploy? I'm using play 2.1.2.
You could try a throw-away commit if you concern is to avoid actually saving the 'minor/dummy' commits to the repo permanently:
Heroku Throwaway Commit
See Section: "Automating the throwaway commit"
The author has basically automated the above with a quick bash script; however, as the author indicates use with caution -- you wouldn't want to use this in other situations with un-tested code.
https://www.darraghoriordan.com/2019/03/02/heroku-push-failed-force-rebuild/
heroku plugins:install heroku-releases-retry
heroku releases:retry
# or
heroku releases:retry --app darragh-starter
If you are just trying to reload the dynos you can issue this from the command line:
heroku restart -a appname
More info https://devcenter.heroku.com/articles/application-offline
This is the first time I've used Heroku, and the fact that I can't find anyone in Google with a similar error to this means I'm likely doing something way wrong:
I'm following the basic Heroku setup guide here to get my NodeJS application deployed to the web. I'm deployed and trying to check my dynos with:
heroku ps:scale web=1
However, when I do this I get the error:
Scaling web dynos... failed
! No such process type web defined in Procfile.
When I run heroku ps I get nothing returned.
In my app's root directory, I have a file named Procfile (with no extension) which contains:
web: node app.js
The app runs locally without any issues (using foreman start).
Question is why is this occurring, how do I remedy it, should I even care?
Processes to be run on Heroku are defined in a simple text file called: Procfile
The Profile contains a line that defines how each of the processes in your application will run. This will be language specific and examples can be seen on the Heroku Devcenter Procfile article
Please note that the Procfile must be spelt exactly, with the first letter capitalized an all others lower case. There is no file extension for the Procfile. This Procfile should be placed in the root of your project and committed to your local git repository before doing a git push heroku master.
Should you mis-type the filename after it has been added to git, you can rename it using git with the command
git mv ProcFile Procfile
The renamed file will be staged so you can commit the changed file with the command
git commit -m "corrected name of Procfile"
I found the solution myself, from here: https://stackoverflow.com/a/7641259/556006
I had the same problem and I just now I found what was wrong. I first
accidently called the file ProcFile instead of Procfile. Simply
renaming that file did not get picked up by git. I had to do a git rm
ProcFile -f first and then add a new (correctly named) Procfile. After
that, it got pushed correctly by git and got picked up correctly by
Heroku.
I just had this issue myself, but in my case, I was missing a space between web: and the starting command in the Procfile.
For example, I had it wrong this way:
web:gunicorn run:app
Fixed it by adding a space after the colon:
web: gunicorn run:app
I am guessing you've never done git push heroku master -- that is, Heroku has never seen your code.