Accessing Meteor Settings in a Self-Owned Production Environment

后端 未结 1 790
无人及你
无人及你 2021-02-02 03:39

According to Meteor\'s documentation, we can include a settings file through the command line to provide deployment-specific settings.

However, the --settings

相关标签:
1条回答
  • 2021-02-02 03:59

    Yes, include the settings contents in an environmental variable METEOR_SETTINGS. For example,

    export METEOR_SETTINGS='{"privateKey":"MY_KEY", "public":{"publicKey":"MY_PUBLIC_KEY", "anotherPublicKey":"MORE_KEY"}}'

    And then run the meteor app as normal.

    This will populate the Meteor.settings object has normal. For the settings above,

    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
    

    For our project, we use an upstart script and include it there (although upstart has a slightly different syntax). However, if you are starting it with a normal shell script, you just need to include that export statement before your node command. You could, for example, have a script like:

    export METEOR_SETTINGS='{"stuff":"real"}'
    node /path/to/bundle/main.js
    

    or

    METEOR_SETTINGS='{"stuff":"real"}' node /path/to/bundle/main.js

    You can find more information about bash variables here.

    0 讨论(0)
提交回复
热议问题