Dyno元数据未显示在“ env”输出中

时间:2019-10-24 06:34:37

标签: ubuntu heroku environment-variables gcloud

我正尝试在Google Cloud Shell上的this guide之后在Heroku上获得dyno元数据,但是它不显示dyno元数据。

当我输入以下命令时:

heroku labs:enable runtime-dyno-metadata -a app_name

它显示以下消息:

Enabling runtime-dyno-metadata for <app name>... done

但是当我运行env命令时,它不显示动态元数据。

我希望这样:

env
HEROKU_APP_ID:                   9daa2797-e49b-4624-932f-ec3f9688e3da
HEROKU_APP_NAME:                 example-app
HEROKU_DYNO_ID:                  1vac4117-c29f-4312-521e-ba4d8638c1ac
HEROKU_RELEASE_CREATED_AT:       2015-04-02T18:00:42Z
HEROKU_RELEASE_VERSION:          v42
HEROKU_SLUG_COMMIT:              2c3a0b24069af49b3de35b8e8c26765c1dba9ff0
HEROKU_SLUG_DESCRIPTION:         Deploy 2c3a0b2
...

但它显示如下内容:

env
BASHRC_PATH=/home/<user-name>/.bashrc
DEVSHELL_PROJECT_ID=<project-id>
LS_COLORS=blah
CREDENTIALS_SERVICE_PORT=8998
SSH_CONNECTION=blah
__TMP_CLOUDSDK_CONFIG=/tmp/tmp.blah
LANG=en_US.UTF-8
TZ=Asia/Dili
CLOUD_SHELL_IMAGE_VERSION=
CLOUDSDK_CONFIG=/tmp/tmp.blah
ASPNETCORE_URLS=http://*:8080
GEM_HOME=/home/<user-name>/.gems
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
BASHRC_GOOGLE_PATH=/google/devshell/bashrc.google
USER=<user-name>
GOPATH=/home/<user-name>/gopath:/google/gopath
PWD=/home/<user-name>
HOME=/home/<user-name>
BROWSER=echo
SHOW_CUSTOM_IMAGE_DEPRECATION=
DEVSHELL_GCLOUD_CONFIG=blah
SSH_CLIENT=127.0.0.1 58262 22
TMUX=/tmp/tmux-1000/default,280,0
TRUSTED_ENVIRONMENT=true
CUSTOM_ENVIRONMENT=false
GEM_PATH=/home/<user-name>/.gems:/usr/local/lib/ruby/gems/2.6.0/
ACTIVE_CUSTOM_IMAGE=
API_DOGFOOD=
SSH_TTY=/dev/pts/0
MAIL=/var/mail/<user-name>
CLOUD_SHELL=true
TERM=screen
SHELL=/bin/bash
DOCKER_HOST=unix:///var/run/docker.sock
DEVSHELL_CLIENT_PORT=8998
GCE_METADATA_HOST=blah
TMUX_PANE=%0
DEVSHELL_CLIENTS_DIR=/var/run/google/devshell
SHLVL=3
PROMPT_COMMAND=history -a;update_devshell_project_id &> /dev/null
LOGNAME=<user-name>
GOOGLE_CLOUD_PROJECT=<project-id>
PATH=/home/<user-name>/gopath/bin:/google/gopath/bin:/google/google-cloud-sdk/bin:/usr/local/go/bin:/opt/gradle/bin:/opt/maven/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/nvm/versions/node/v10.14.2/bin:/google/go_appengine:/google/google_appengine]
PS1=\[\e]0;${DEVSHELL_PROJECT_ID:-Cloud Shell}\a\]\u@cloudshell:\[\033[1;34m\]\w$([[ -n $DEVSHELL_PROJECT_ID ]] && printf " \[\033[1;33m\](%s)" ${DEVSHELL_PROJECT_ID} )\[\033[00m\]$ \[\033k$([[ -n $DEVSHELL_PROJECT_ID ]] && printf "(%s)" ${DEVSHELL_PROJECT_ID} || printf "cloudshell")\033\\\]
HISTSIZE=1000CLOUDSDK_DIAGNOSTICS_HIDDEN_PROPERTY_WHITELIST=compute/gce_metadata_read_timeout_sec
HISTFILESIZE=1000
DEVSHELL_IP_ADDRESS=blah
DEVSHELL_SERVER_URL=https://ssh.cloud.google.com
_=/usr/bin/env

如何动态访问dyno元数据?

1 个答案:

答案 0 :(得分:1)

该输出看起来像是给您的 Google shell的。

Heroku元数据环境变量不会出现在您的本地shell中,而是出现在dyno的环境中。 您的应用应该可以访问它们。

尝试在Heroku上运行它,例如通过

heroku run env