yarn global add pm2
edit the file ~/.bashrc
and add the following line in the end
export PATH=$(yarn global bin):$PATH
You can close the file now
source ~/.bashrc
pm2 is now accessible from terminal
now see a example of a pm2_config_file.json
{
"apps": [
{
"name": "POS",
"cwd": "./www",
"script": "python3 -m http.server 3000"
}
]
}
Now the most important command: with this, check the output to know which script to run to recover all process if the server broke
pm2 startup ubuntu -u <usuario>
then
pm2 save
pm2 list
pm2 log
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
pm2 save
[PM2] Remove init script via:
pm2 unstartup systemd
+---------------------------------------+