admin管理员组

文章数量:1323023

I have a staging and production server both running a Sails.js app (www.sailsjs). I have experienced pm2 restarting my app randomly without at correlation or pattern. I've checked the following for any pattern: - Memory usage leading up to restart - sometimes it's ~320MB and others it's ~410MB - Events/Requests/Errors nothing in my Nginx, Node, PM2, or App logs show errors or any concerns

This happens in both staging and production servers in cluster mode or fork. It does NOT happen locally, at least I haven't experienced it.

Info Servers: Digitalocean droplets 2GB RAM 2 CPU/Core Ubuntu 14.04 lts Node: v4.4 PM2: 1.0.2

Also, the pm2 list mand shows the app running for 3h but says there have been zero restarts when I know for a fact the app has been running for several days. I also have a keymetrics.io account that monitors the server which shows me the restarts of pm2 (the pm2.log correlates these restarts):

I have a staging and production server both running a Sails.js app (www.sailsjs). I have experienced pm2 restarting my app randomly without at correlation or pattern. I've checked the following for any pattern: - Memory usage leading up to restart - sometimes it's ~320MB and others it's ~410MB - Events/Requests/Errors nothing in my Nginx, Node, PM2, or App logs show errors or any concerns

This happens in both staging and production servers in cluster mode or fork. It does NOT happen locally, at least I haven't experienced it.

Info Servers: Digitalocean droplets 2GB RAM 2 CPU/Core Ubuntu 14.04 lts Node: v4.4 PM2: 1.0.2

Also, the pm2 list mand shows the app running for 3h but says there have been zero restarts when I know for a fact the app has been running for several days. I also have a keymetrics.io account that monitors the server which shows me the restarts of pm2 (the pm2.log correlates these restarts):

Share Improve this question asked Apr 12, 2016 at 2:22 Cory RobinsonCory Robinson 5,2826 gold badges40 silver badges59 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 6

If you look at the PM2 help, pm2 --help, you will see an option --no-autorestart which says start an app without automatic restart. That should do it.

But you want PM2 to to be able to restart when it is out of memory. You can increase the max memory until restart with the --max-memory-restart option.


Example with max-memory-restart set to 5000mb:

PM2 start --name my-process --max-memory-restart 5000M index.js

本文标签: javascriptpm2 app restarts randomly without reasonStack Overflow