Home > Blockchain >  Node app restarting on load - digitalocean
Node app restarting on load - digitalocean

Time:01-27

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. 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

Node: 12.22.12 RAM: 8GB

Added NODE_OPTIONS and GENERATE_SOURCEMAP=false

CodePudding user response:

in Pm2 config file, there is a max memory reload settings

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

CodePudding user response:

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. Simply do pm2 kill and deploy your app.

  • Related