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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With