我希望使用pm2和环境变量(如--nouse-idle-notification
或--max-old-space-size=2048
)启动节点。
但是,不管我做什么,它都不是传递节点变量。我用pm2和一个配置文件启动我的应用程序。配置文件如下所示:
{
"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"
}]
}
(如您所见,我尝试以多种方式传递节点变量)
然后,我以以下内容开始这个应用程序:
pm2 restart pathtojsonfile --env production
一切都在正常启动,我在代码中看到了像"MY_APP“这样的变量。然而,现在当我用"top“来查看这个过程时,我只看到:
node /opt/myapp/app.js
当我永久地或手动地启动应用程序时,我可以看到这样的过程:
node --max-old-space-size=2048 --nouse-idle-notification /opt/myapp/app.js
pm2只是没有显示那些节点参数,还是它们真的没有传入?( pm2启动进程使用的内存较少)
发布于 2016-12-08 16:09:00
通过使用"node_args":“--最大旧空间大小=2048年-nouse-空闲-通知”,您做了正确的事情,并且考虑到了这些参数。
PM2重命名进程并在进程标题中删除指定的节点参数。
https://stackoverflow.com/questions/41030594
复制相似问题