Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Heroku Release Number / Code Version From a Running Dyno

Tags:

heroku

Is it possible to get a unique key per slug / release from a running dyno? I was following this article to setup RAILS_CACHE_ID (for expiring etags after deployments) but found that the dynos no longer ship with GIT configured (which causes this error):

fatal: Not a git repository (or any parent up to mount point /app)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I also considered setting it in a config/initializers to the current Time but obviously that wouldn't work across multiple dynos. Any ideas?

like image 513
Kevin Sylvestre Avatar asked Dec 12 '14 22:12

Kevin Sylvestre


People also ask

How to download code from deployed app version in Heroku?

- Heroku Help How to download code from deployed app version ? Determine the release version number you want the code/slug to be downloaded from. The CLI command heroku releases -a <app_name> will show you all releases for your app. Run heroku slugs -a <app_name> to find the slug ID for the particular version selected.

How do I release a dyno in Heroku?

Use the heroku ps command to see your release command running. The dyno type can be set using `heroku ps:type release= {type}, but only after the release phase is run for the first time. If the release command exits with a non-zero exit status, or if it’s shut down by the dyno manager, the release fails.

How does Heroku scale apps?

The Heroku Platform uses the container model to run and scale all Heroku apps. The containers used at Heroku are called “dynos.” Dynos are isolated, virtualized Linux containers that are designed to execute code based on a user-specified command. Your app can scale to any specified number of dynos based on its resource demands.

How do I retry a failed release in Heroku?

In such occurrences, the releases-retry CLI plugin can be used to retry a failed release without needing to trigger a new build on the app. To check on the status of a release, including failed releases and releases that are pending due to a long-running release command, run heroku releases.


1 Answers

There's a new (Nov 2015) labs feature which does just what you need "Dyno metadata" https://devcenter.heroku.com/changelog-items/768

heroku labs:enable runtime-dyno-metadata -a <app name>

Then on heroku:

~ $ env
HEROKU_APP_ID:                   9daa2797-e49b-4624-932f-ec3f9688e3da
HEROKU_APP_NAME:                 example-app
HEROKU_DYNO_ID:                  1vac4117-c29f-4312-521e-ba4d8638c1ac
HEROKU_RELEASE_VERSION:          v42
HEROKU_SLUG_COMMIT:              2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
HEROKU_SLUG_DESCRIPTION:         Deploy 2c3a0b2
like image 87
Richard Boardman Avatar answered Sep 22 '22 08:09

Richard Boardman