是的,将设置内容包含在环境变量METEOR_SETTINGS
中。例如,
export METEOR_SETTINGS='{"privateKey":"MY_KEY", "public":{"publicKey":"MY_PUBLIC_KEY", "anotherPublicKey":"MORE_KEY"}}'
然后像平常一样运行Meteor应用程序。
这将正常填充Meteor.settings对象。对于上面的设置,
Meteor.settings.privateKey == "MY_KEY" #Only on server
Meteor.settings.public.publicKey == "MY_PUBLIC_KEY" #Server and client
Meteor.settings.public.anotherPublicKey == "MORE_KEY" #Server and client
对于我们的项目,我们使用一个upstart脚本并在其中包含它(尽管upstart具有稍微不同的语法)。然而,如果您使用普通shell脚本启动它,您只需要在node命令之前包含那个export
语句。例如,您可以有一个类似这样的脚本:
export METEOR_SETTINGS='{"stuff":"real"}'
node /path/to/bundle/main.js
或者
METEOR_SETTINGS='{"stuff":"real"}' node /path/to/bundle/main.js
您可以在这里找到有关bash变量的更多信息。
Meteor.settings.privateKey
会按预期工作吗? - JT703