I am using PM2 to run my node app as a service. My Node app is RAM Hungry so it consumes around 300 to 800mb of ram depending on traffic. My DigitalOcean droplet has 1GB RAM.
Sometimes out of the blue, my app disappears from running services and I see nothing when I give command pm2 list
As far as I know, pm2 should take care of such crashes itself and restart the app when ever such crash happens, but it doesn't restart it instead do anything.
I am now looking for some solution that can auto restart my app when it crashes, and I have to use pm2 to use it a service.
Can you check the logs if the machine rebooted or not ?
You can use this command to see the last reboot time :
last | grep reboot
Or even the
uptime
Command to see for how long you are running.
If it does, that should be the problem. pm2 got a good solution management for that :
$ pm2 startup # Detect init system, generate and configure pm2 boot on startup
$ pm2 save # Save current process list
$ pm2 resurrect # Restore previously saved processes
$ pm2 unstartup # Disable and remove startup system
If your apps are running on ports that should be open with your firewalls, you need to do the same kind of saving with your firewall too. With Ubuntu I know there is a very nice package for that but I am pretty sure you can find something equivalent on any system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With