Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Heroku app name/URL from inside the app

Tags:

heroku

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.

like image 903
Alexander Todorov Avatar asked Sep 24 '12 18:09

Alexander Todorov


People also ask

What is my Heroku app URL?

By default, a Heroku app is available at its Heroku domain, which has the form [name of app]. herokuapp.com . For example, an app named serene-example-4269 is hosted at serene-example-4269.herokuapp.com .

How do I rename my Heroku app URL?

If you want to rename your app, run heroku apps:rename [newname] in the app folder and swap out newname with the name that you want to change to. You can also see a complete list of Heroku apps that you're a creator or contributor to by running heroku apps .


2 Answers

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) 
like image 194
ehc Avatar answered Dec 06 '22 13:12

ehc


Dyno Metadata was introduced December 2015. It’s currently a labs feature which must be enabled first.

Dyno metadata gives the dyno easy access to information about the app and environment. Examples of available dyno metadata include details about the release, dyno size, application name as well as the unique identifier for the particular running dyne.

https://devcenter.heroku.com/articles/dyno-metadata

like image 37
James Beith Avatar answered Dec 06 '22 13:12

James Beith