问题
I have a node app ready which is workable, but has known and unknown bugs which crashes the node app. In such cases it would be nice if pm2 can restart the node app. Is this feature already available in pm2 ?
回答1:
Yes, it does this by default and there is even a watch option to restart on changes.
回答2:
Also, check new excellent option
--exp-backoff-restart-delay=100 (msec, not sec!)
pm2 will restart crashed app after 100 msec, then step-by-step increase restart-delay to 15 secunds
回答3:
This may help:
# Generate Startup Script
$ pm2 startup
# Freeze your process list across server restart
$ pm2 save
# Remove Startup Script
$ pm2 unstartup
More details here
来源:https://stackoverflow.com/questions/26135371/can-the-pm2-node-module-restarts-the-app-after-crash-automatically