Java – you can programmatically access the current heroku dyno ID / name?
•
Java
On heroku, can you get some identifier of dyno currently executing code from the program through the program? For example, dyno name (such as "web. 1" or "worker. 1") or other ID
If so, what do you do in Java?
Solution
There is always the host name of the machine (looks like d.long_guid), I think (although I didn't try) this should work:
String localhostname = java. net. InetAddress. getLocalHost(). getHostName();
In addition, there is a famous secret, but you can get the "web. 1" and "web. 2" IDS by looking at the value of the environment variable PS1
String hostId = System. getenv(“PS1”)
EDIT 2013-July-26
According to Heroku changelog, the local environment variable dyno now replaces PS, which replaces PS1
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码