使用设置参数在 Node 下运行 Meteor Build [英] Running Meteor Build under Node with settings argument
问题描述
通常在开发时我会使用 meteor run --settings settings.json
.这工作正常,可以在控制台上使用 Meteor.settings
查看浏览器中的设置.
Typically when developing I would use meteor run --settings settings.json
. This works fine and can view the settings in the browser with Meteor.settings
on the console.
我现在正在为生产而构建,使用 meteor build
,我查看了文档,但在构建过程中没有任何地方可以添加 settings
.
I am now build for production, using meteor build
, I've looked at the documentation and there is nowhere to add settings
during the build process.
所以构建运行,我有我的 .tar.gz
文件,它被加载到生产中,然后我解压/压缩文件夹并运行启动脚本.
So the build runs and I have my .tar.gz
file, it's loaded to production and then I untar/compress the folder and run the start script.
它以npm start
进入程序,package.json部分如下所示(忽略停止脚本);
It enters the program with npm start
and the package.json section looks like this (ignore the stop script);
{
"name": "myapp",
"scripts": {
"start": "node main.js --settings settings.json",
"stop": "killall node"
}
}
当我查看我的应用时,它没有收集这些设置.就好像捆绑时它不期望争论.我之前也尝试过永远使用,但我对此也不满意.
When I look at my app it is not collecting these settings. It is as if when bundled it doesn't expect the arguements. I also tried using forever beforehand, but I had no joy with this either.
任何帮助将不胜感激,开始希望我从来没有打扰流星:)
Any help would appreciated, start to wish I never bothered with Meteor :)
推荐答案
可以参考Meteor指南 > 生产 > 部署和监控 > 环境变量和设置
设置.这些位于通过 --settings
Meteor 命令行标志或字符串化到 METEOR_SETTINGS
环境变量中的 JSON 对象集.
Settings. These are in a JSON object set via either the
--settings
Meteor command-line flag or stringified into theMETEOR_SETTINGS
environment variable.
至于设置环境变量,如果您使用第三方主机,您可能有一个 GUI 或 CLI 来定义它们.
As for setting environment variables, if you use a 3rd party host, you may have a GUI or CLI to define them.
否则,您应该拥有大量资源,包括关于 SO:
Otherwise, you should have plenty resources including on SO:
简而言之,它应该是这样的:
In short, it should look like:
METEOR_SETTINGS='{"key":"value"}' node main.js
您也可以尝试使用 bash cat
命令提取文件内容:$(cat settings.json)
You can also try the bash cat
command to extract the content of a file: $(cat settings.json)
这篇关于使用设置参数在 Node 下运行 Meteor Build的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!