I've read many posts that talk about keeping node running in the background using nohup, forever and pm2. But I'm still uncertain which is the optimal choice and would appreciate some guidance.
Background - running a MEAN stack app on an Apache server which uses Ubuntu version 16. App.js location is /var/www/. I'm currently using forever to keep the app running in the background when I exit the terminal. I understand that if I use nohup, the command would be
nohup node /var/www/<project_name>/app.js > stdout.txt 2> stderr.txt &
What I want to ensure is that regardless of 1) how I exit the terminal (by typing exit or simply clicking the X on the top right) and 2) which operating system the app is deployed on, no background service will terminate in a way that disrupts my app when I exit the terminal. To that end, what's the best approach to running the app? nohup, forever or pm2? I also understand that some people have a preference for pm2 over forever. What does pm2 offer than forever doesn't?
supervisord
is better. – Mielke