PM2 is a process management system to keep certain processes a live. This could be either a script you have created or a socket server for example.
How do you install PM2 on a ubuntu server? Very easy, run this command:
npm install pm2@latest -g
Note: You need to have npm installed before you can run this command. You can also use yarn to install PM2.
And thats it! You are now ready to start using PM2 to run your processes.
Lets say you have a bash script called socket.sh to run a socket server. You can start script and keep it alive by running:
pm2 start socket.sh
You will now get a list right away of the running processes that PM2 is keeping alive for you. (There is a lot of configuration parameters you can send too)