Heroku and Environments -domains are not working - heroku

I am finding that managing production and staging env's on heroku truly a painful process esp with domains, git etc.
1) I created app called htest.
2) In the htest directory I did the below:
heroku create --app htest-staging --remote staging
heroku create --app htest-production --remote production
heroku domains:add staging.mydomain.com --app htest-staging --remote staging
heroku domains:add production.mydomain.com --app htest-production --remote production
3) I committed the app and started service
git push staging master
heroku ps --app htest-staging --remote staging
3) I add domain to route53 with the cname of htest-staging.herokuapp.com
heroku info --app htest-staging
=== htest-staging
Web URL: http://htest-staging.herokuapp.com/
as expected I get web page not found.
What is even more troubling is that when I go to http://htest-staging.herokuapp.com/ I get this on the page:
Heroku | Welcome to your new app!
Refer to the documentation if you need help deploying.
My python app should have said hello world.
So..how do I resolve?

Related

How can you see Heroku logs for git deployed app on Heroku

If we deploy app normally on heroku-cli, we can easily see all the logs by using
$ heroku logs
But how can we check heroku logs if we have connected the heroku app with git repository, then we can't use heroku logs

How to redeploy my laravel application to heroku when I deleted the url that heroku gave me

I have deleted that in dashboard due to some errors during deployment with
$ git push heroku master
and now I want to deploy my laravel application once again. But everytime during deployment it keeps on pushing to that old url. And not to the one that heroku gave me during when I type
$ heroku create
What seems to be my problem ?
Remove old remote
git remote rm heroku
and add again with
heroku git:remote -a your-app-name
or
git remote set-url heroku <new-url>

Copy production database to staging heroku

How can I pull my production database to my staging server on heroku?
I have two remotes, production and staging.
From the documentation it appears that I want to run heroku pg:copy COBALT GREEN --app sushi but it isn't clear what all the arguments mean. How can I copy my production database to my staging database?
First use:
heroku pg:info -a your_production_app
to retrieve the name of the environment variable that has the URL of your production db, e.g HEROKU_POSTGRESQL_WHITE_URL.
Then:
heroku pg_info -a your_staging_app
to get the same for your staging app (e.g. DATABASE_URL).
Finally:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
Just to add a clarification to the #Yoni Rabinovitch's answer.
I do not have named database so I needed to replace name with DATABASE_URL instead. It is not much intuitive to duplicate DATABASE_URL, is it?
So instead of:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
I used
heroku pg:copy your_production_app::DATABASE_URL DATABASE_URL -a your_staging_app
Hope this might help somebody.

Multiple apps in git remotes when trying to access rails console

I have two git branches, staging and production, and I deployed them on Heroku in the same Heroku acccount. Suppose my app names are app1.heroku-app.com and app2.heroku-app.com and the remote names are heroku-staging and heroku-production,respectively. I deployed both apps on Heroku. After I login to Heroku from the console using heroku login and then try to access a Rails console using heroku run rails c, I get this message :
▸ multiple apps in git remotes
▸ remotes: heroku-staging heroku-production
How can I access a console?
If there's only one Heroku remote, heroku can infer which you want. When there are multiple (or if you want to access an application that doesn't have a remote in this Git repo, or when you're not in a Git repo at all), you need to use the --app option to specify which application you want a console on.
$ heroku --help
Usage: heroku COMMAND [--app APP] [command-specific-options]
$ heroku run rails c --app app1
$ heroku run rails c --app app2
In addition to being able to specify the app as a per-command flag, if you'd like for there to be a default environment, setting the environment variable HEROKU_APP to the app you want will make it so that heroku commands don't rely on git config.
$ heroku logs
› Error: Multiple apps in git remotes
...
$ export HEROKU_APP=app1
$ heroku logs
2018-12-31T03:56:34.888350+00:00 app[web.1]: 1.2.3.4 ...

Transfer heroku database from one bamboo app to another cedar app

Is there a faster way to transfer database on one app to another, without using capture and restore process which is taking 3hrs in my case.
We are trying to move to Cedar app and can't afford a 3hrs downtime.
Is it possible to:
1. create a follower on current prod app
2. allow to catch up.
3. maintenace on
4. unfollow the follower on current prod app that I created on step 1
5. Promote that follower to another app.
6. maintenance off
Similar to this link: https://devcenter.heroku.com/articles/fast-database-changeovers
but trying to promote it to another app.
Is it possible?
Regards
If you are on one of the production plans for your database, you're in luck. There is a secret flag that you can use. It doesn't work for the dev plans, only crane and above. If your Bamboo app has a crane or better database, you can create a fork of it by grabbing the DATABASE_URL, and then running:
heroku addons:add heroku-postgresql:crane --fork="<PASTE DATABASE_URL HERE>" --app your-cedar-app
Or if you prefer, for minimal downtime using a procedure similar to our fast changeover:
heroku addons:add heroku-postgresql:crane --follow="<PASTE DATABASE_URL HERE>" --app your-cedar-app
heroku pg:wait --app your-cedar-app # let the new database boot
heroku pg:info --app your-cedar-app # Make sure it's caught up, Behind By should be =~ 0.
heroku maintenance:on --app your-cedar-app
heroku pg:unfollow HEROKU_POSTGRESQL_<color of new database> --app your-cedar-app
heroku pg:promote HEROKU_POSTGRESQL_<color of new database> --app your-cedar-app # make it the primary
heroku maintenance:off --app your-cedar-app

Resources