【发布时间】:2015-04-09 22:56:05
【问题描述】:
当我运行cf env <app-name> 时,它会显示我使用cf set-env 设置的所有环境变量,但我看不到VCAP_SERVICES 环境变量。如何查看该变量的值?
【问题讨论】:
-
cf 环境 APP_NAME
当我运行cf env <app-name> 时,它会显示我使用cf set-env 设置的所有环境变量,但我看不到VCAP_SERVICES 环境变量。如何查看该变量的值?
【问题讨论】:
从 cf 程序的 6.10 版开始,VCAP_SERVICES 环境现在将与其他环境变量一起显示,使用命令 cf env <app-name>。
要升级您的cf 程序,请在发布页面下载相应版本:https://github.com/cloudfoundry/cli/releases
【讨论】:
使用 cf env 命令查看应用程序的 Cloud Foundry 环境变量。 cf env 显示以下环境变量:
The VCAP_SERVICES variables existing in the container environment
The user-provided variables set using the cf set-env command
详情请参考:
http://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html
【讨论】:
cf env app-name 给出 VCAP_SERVICES 值。
【讨论】:
这里是小sn-p列出PCF的所有环境变量:
cf ssh <App_Name> -c "python -c 'import os, json; print(json.dumps({key:value for (key,value) in os.environ.items()}, indent = 2))'"
{
"INSTANCE_GUID": "315c18fb-e031-4e6e-67c4-84d1",
"CF_INSTANCE_PORT": "61064",
"CF_INSTANCE_KEY": "/etc/cf-instance-credentials/instance.key",
"USER": "vcap",
"INSTANCE_INDEX": "0",
.
.
.
.
"PWD": "/home/vcap",
"VCAP_APP_PORT": "8080"
}
}
【讨论】:
cf env your-app-name 提供 VCAP_SERVICES 值,但仅当您的应用程序与服务绑定时,否则您将只有 VCAP_APPLICATION 变量。
【讨论】: