【发布时间】:2015-07-13 09:56:24
【问题描述】:
在设置服务器时,我注意到使用了环境变量 process.env.PORT。还有其他类似的变量吗?我在哪里可以看到所有这些?
【问题讨论】:
-
heroku run printenv -
只是出于好奇,为什么没有选择这个答案?
标签: web-services heroku environment-variables
在设置服务器时,我注意到使用了环境变量 process.env.PORT。还有其他类似的变量吗?我在哪里可以看到所有这些?
【问题讨论】:
heroku run printenv
标签: web-services heroku environment-variables
以下命令将显示环境变量的所有,而不仅仅是那些从heroku config 可见的环境变量:
heroku run printenv
【讨论】:
sort 将其作为一个更好的解决方案:heroku run printenv | sort
WEB_CONCURRENCY 是什么,起初对结果感到困惑),那么将您的测功机大小与您的大小相匹配很重要'将使用:heroku run -s performance-L printenv 用于性能-L 测功机。
heroku config 不显示端口。所以,如果你需要一切,它是不完整的。这将创建一个一次性的测功机并显示所有内容。
从这里:https://devcenter.heroku.com/articles/getting-started-with-nodejs#console
在一次性测功机中运行控制台,然后在 > 提示符下键入“console.log(process.env)”:
$ heroku run node
Running `node` attached to terminal... up, run.4778
> console.log(process.env
... )
{ BUILDPACK_URL: 'https://github.com/MichaelJCole/heroku-buildpack-nodejs.git#wintersmith',
TERM: 'xterm',
SENDGRID_USERNAME: 'unicorns@heroku.com',
COLUMNS: '80',
DYNO: 'run.4778',
PATH: '/app/bin:/app/node_modules/.bin:bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin',
PWD: '/app',
PS1: 'fairydust',
LINES: '22',
SHLVL: '1',
HOME: '/app',
SENDGRID_PASSWORD: 'ponies',
PORT: '52031',
_: '/app/bin/node' }
undefined
【讨论】:
【讨论】:
请参阅https://devcenter.heroku.com/articles/config-vars:似乎有一个命令可以告诉您环境变量是什么。
$ heroku config
看看这是否适合你。
编辑:上面链接的 heroku 文档似乎是错误的。试试这个:
$ heroku config -s --app <appname>
【讨论】: