简体   繁体   English

节点应用程序在加载时重新启动 - digitalocean

[英]Node app restarting on load - digitalocean

I've seen the pm2 logs and report and there I'm getting JavaScript heap out of memory but I've increased the heap limit to 12 GB and also added GENERATE_SOURCEMAP=false into the environment variables.我已经看到了 pm2 日志和报告,我从 memory 中得到了JavaScript 堆,但我已经将堆限制增加到 12 GB,并且还在环境变量中添加了 GENERATE_SOURCEMAP=false。 Locally, by just increasing the max-old space I've resolved the issue but on the server, getting the same error.在本地,通过增加最大旧空间我已经解决了这个问题但是在服务器上,得到了同样的错误。 After consuming ~2.5GB of memory, my node app is getting restarted在消耗了 ~2.5GB 的 memory 之后,我的节点应用程序正在重新启动

Node: 12.22.12 RAM: 8GB节点:12.22.12 内存:8GB

Added NODE_OPTIONS and GENERATE_SOURCEMAP=false添加了 NODE_OPTIONS 和 GENERATE_SOURCEMAP=false

in Pm2 config file, there is a max memory reload settings在 Pm2 配置文件中,有一个最大 memory 重新加载设置

// ecosystem.config.js
module.exports = {
  apps: [{
    name: 'api',
    script: 'api.js',
    max_memory_restart: '10000M' // change this
  }]
}

I was facing node app restart because of the pm2... Earlier, I had set max_memory_restart: '2G' so pm2 cached that value and when I changed it into the '15G' pm2 didn't get that.由于 pm2,我正面临节点应用程序重启......早些时候,我设置了 max_memory_restart: '2G' 所以 pm2 缓存了该值,当我将它更改为 '15G' 时,pm2 没有得到它。 Simply do pm2 kill and deploy your app.只需执行 pm2 kill 并部署您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM