How to config Meteor on AWS/EBS using METEOR_SETTINGS environment variable

后端 未结 3 1034
夕颜
夕颜 2020-12-14 12:55

Trying to set up a Meteor on an AWS/EBS (Amazon Web Services, Elastic Beanstalk) environment.

A Meteor dev-run can be passed a command line flag: --settings s

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 13:16

    Tested another workaround.

    after meteor build --directory edit main.js as following

    process.argv.splice(2, 0, 'program.json');
    var settingfilename = './settings.json';
    if (process.env.METEOR_SETTING_FILE)
      settingfilename = process.env.METEOR_SETTING_FILE;
    var settings = require(settingfilename);
    if (settings) {
      try {
        process.env.METEOR_SETTINGS = JSON.stringify(settings);
      } catch (e) {
        console.error(e);
      }
    }
    process.chdir(require('path').join(__dirname, 'programs', 'server'));
    require('./programs/server/boot.js');
    

    and copy settings.json into bundle/ and eb init and eb deploy.

    you can set the other settings file with adding METEOR_SETTING_FILE at Environment Properties in Configuration tab from EB Console.

    editing file is needed after every build.


    added the patch file to use in the build script like ed - ../build/bundle/main.js < main.js.patch

    main.js.patch

    8a
    var settingfilename = './settings.json';
    if (process.env.METEOR_SETTING_FILE)
      settingfilename = process.env.METEOR_SETTING_FILE;
    var settings = require(settingfilename);
    if (settings) {
      try {
        process.env.METEOR_SETTINGS = JSON.stringify(settings);
      } catch (e) {
        console.error(e);
      }
    }
    // console.log (JSON.stringify(process.env));
    .
    w
    

提交回复
热议问题