Heroku pipeline. Run commands on production app (not staging)

房东的猫 提交于 2019-12-11 07:30:22

问题


I am using the heroku pipeline. I set up my two apps. One for staging, one for production. Both use "production" as the environment variable.

If I run heroku run rails c I can access the console on my staging app. The heroku website, allows to run a console in the production app as well, but only with the predifined heroku run part. Which means if for whatever reason I need to run a more fundamental command (for example heroku pg:reset; I know I know), I can't.

So is there a way to specify which heroku app I want to run the commands at? Something like heroku pg:reset production-app-name maybe?

I am using cloud9 as an IDE, not sure if that makes a difference.


回答1:


Yes, you got it almost right, just add --app before the app-name:

$ heroku pg:reset --app production-app-name

In fact, if you have more than one app configured (run heroku apps to list them), you will get an error; for example, try running a safer command:

$ heroku logs

If you have more than one app, the output will be:

 ▸    Error: Multiple apps in git remotes
 ▸    Usage: heroku logs --remote production
 ▸       or: heroku logs --app production-app-name
 ▸
 ▸    Your local git repository has more than 1 app referenced in git remotes.
 ▸    Because of this, we can't determine which app you want to run this command against.
 ▸    Specify the app you want with --app or --remote.
 ▸
 ▸    Heroku remotes in repo:
 ▸    production      (production-app-name)
 ▸    staging         (staging-app-name)
 ▸
 ▸    https://devcenter.heroku.com/articles/multiple-environments


来源:https://stackoverflow.com/questions/44251634/heroku-pipeline-run-commands-on-production-app-not-staging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!