[英]pm2 with systemd and passing node argument
I want to start node with pm2 and environment variables like --nouse-idle-notification
or --max-old-space-size=2048
.我想使用--nouse-idle-notification
和环境变量(如--nouse-idle-notification
或--max-old-space-size=2048
启动节点。
However, whatever I do, it is not passing the node variables.但是,无论我做什么,它都不会传递节点变量。 I start my app with mp2 and a configuration file.我用 mp2 和一个配置文件启动我的应用程序。 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.一切都正常启动,我在我的代码中看到了像“MY_APP”这样的变量。 However, now when I look at the process with "top" I only see:但是,现在当我用“top”查看过程时,我只看到:
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? pm2 只是没有显示这些节点参数还是它们真的没有传入? (The pm2 started process uses less memory) (pm2 启动的进程使用较少的内存)
下面是使用 node-args 启动 pm2 的 extact 命令
pm2 start app.js --node-args="--max-old-space-size=4096"
By using "node_args": "--max-old-space-size=2048 --nouse-idle-notification" you did the right thing and these arguments are taken into account.通过使用 "node_args": "--max-old-space-size=2048 --nouse-idle-notification" 你做了正确的事情,这些参数被考虑在内。
PM2 renames the process and drop the specified node argument in the process title. PM2 重命名进程并在进程标题中删除指定的节点参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.