如何从应用程序内部获取Heroku应用程序名称/ URL [英] How to get Heroku app name/URL from inside the app

查看:176
本文介绍了如何从应用程序内部获取Heroku应用程序名称/ URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在致力于 http://www.dif.io 的注册代理,以便跟踪部署在Heroku上的应用程序。我错过了部署的应用程序的部分信息。注册代理是一个脚本(通常用app本地语言编写),它被设计为在部署后执行(例如,heroku运行,或者通过一些post部署钩子automaticaly)。



如何从应用程序中获取应用程序名称,URL和某些UUID标识符,最好是从某些ENV变量中获取?我需要它可以在各种语言之间移植。



我探索了一个示例Python应用程序,并且缺少上述所有信息。只有几个ENV变量与Python相关。 dyno主机名看起来像是一个UUID。

我可以使用类似这样的东西,但没有用户/密码要求:
https://addons.heroku.com/provider/resources/technical/reference/app-info



请指出正确的文档。

解决方案

命令 app:info 似乎不再是 heroku 命令,而只是 info 会做同样的事情:

  heroku info -s | grep web_url | cut -d = -f2 

或者设置变量

  heroku config:set HEROKU_URL = $(heroku info -s | grep web_url | cut -d = -f2)


I'm working on a registration agent for http://www.dif.io to enable tracking of apps deployed on Heroku. I'm missing some pieces of information for the deployed app. The registration agent is a script (usually written in the app native language) which is designed to be executed after deployment (heroku run for example or automaticaly via some post deploy hook if any).

How do I get the application name, URL and some UUID identifier from inside the app, preferably from some ENV variables? I need it to be portable between languages.

I explored a sample Python application and all of the above info is missing. There are only couple more ENV variables related to Python. The dyno hostname however looks like an UUID.

I could use something like this but without the user/password requirements: https://addons.heroku.com/provider/resources/technical/reference/app-info

Please point me to the correct docs.

解决方案

The command app:info no longer seems to be a heroku command but just info will do the same thing so:

heroku info -s | grep web_url | cut -d= -f2

or to set the variable

heroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)

这篇关于如何从应用程序内部获取Heroku应用程序名称/ URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆