Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 + Meteor Environment Setup

Tags:

meteor

I am trying to setup Meteor to use pm2 (https://github.com/Unitech/pm2) instead of forever as the node process monitor. I have had no luck in getting the environment variables that a Meteor application needs to be seen by the pm2 process.

Here is my process:

export MONGO_URL="mongodb://localhost:27017/meteor"
export PORT=4000
export ROOT_URL="https://beta.example.com/"
pm2 start main.js --name MyMeteorApp

In the error log from pm2 I see that my Meteor application is complaining that it cannot find MONGO_URL.

Is there a specific way that I need to do the exports in order to work with pm2?

like image 793
DigiLord Avatar asked Dec 11 '13 15:12

DigiLord


1 Answers

You can create process.json (PM2 fleet configuration file) file where you can specify environment variables.

For example:

{
  "apps": [
    {
      "name": "MyMeteorApp",
      "script": "./main.js",
      "log_date_format": "YYYY-MM-DD",
      "exec_mode": "fork_mode",
      "env": {
        "PORT": 4000,
        "MONGO_URL": "mongodb://localhost:27017/meteor",
        "ROOT_URL": "https://beta.example.com/"
      }
    }
  ]
}

for start: pm2 start processes.json

like image 53
ruX Avatar answered Dec 15 '22 07:12

ruX