I have a PM2 process for my NodeJS server and it crash after few minutes. I read somewhere I need to run PM2 as root to not crash.
So I do :
debian@vps:~$ pm2 start server
[PM2] Applying action restartProcessId on app [server](ids: [ 1 ])
[PM2] [server](1) ✓
[PM2] Process successfully started
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1 │ server │ fork │ 991 │ online │ 0% │ 13.8mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
Current process list running is not in sync with saved list. App app differs. Type 'pm2 save' to synchronize.
debian@vps:~$ pm2 stop server
[PM2] Applying action stopProcessId on app [server](ids: [ 1 ])
[PM2] [server](1) ✓
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1 │ server │ fork │ 991 │ stopped │ 0% │ 0b │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
Current process list running is not in sync with saved list. App app differs. Type 'pm2 save' to synchronize.
debian@vps:~$ sudo pm2 start server
sudo: pm2: command not found
So I can't run it as root?