I want to start node with pm2 and environment variables like --nouse-idle-notification
or --max-old-space-size=2048
.
However, whatever I do, it is not passing the node variables. I start my app with pm2 and a configuration file. The configuration file looks like:
{
"apps" : [{
"env": {
"NODE_PATH": "/usr/bin/node",
"interpreter_args": "--max-old-space-size=2048 --nouse-idle-notification"
},
"env_development": {
"NODE_ENV": "development"
},
"env_production" : {
"NODE_ENV": "production",
"APP_TYPE": "web"
},
"exec_mode" : "fork",
"name" : "MyApp",
"script" : "/opt/myapp/app.js",
"watch" : false,
"out_file" : "/var/log/app.log",
"error_file" : "/var/log/app.log",
"combine_logs": true,
"node_args": "--max-old-space-size=2048 --nouse-idle-notification",
"args": "--max-old-space-size=2048 --nouse-idle-notification"
}]
}
(as you can see I try to pass in the node variables in multiple ways)
I then start the app with:
pm2 restart pathtojsonfile --env production
Everything is starting up properly and I see variables like "MY_APP" in my code. However, now when I look at the process with "top" I only see:
node /opt/myapp/app.js
When I start the app with forever or manually I can see the process like:
node --max-old-space-size=2048 --nouse-idle-notification /opt/myapp/app.js
Is pm2 just not showing those node arguments or are they really not passed in? (The pm2 started process uses less memory)
Below is extact command to start pm2 with node-args
pm2 start app.js --node-args="--max-old-space-size=4096"
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