Skip to content

Instantly share code, notes, and snippets.

@luizhenriquefbb
Created April 4, 2020 20:36
Show Gist options
  • Save luizhenriquefbb/231d88dfbbc537d9105969d672f9519d to your computer and use it in GitHub Desktop.
Save luizhenriquefbb/231d88dfbbc537d9105969d672f9519d to your computer and use it in GitHub Desktop.
[pm2] how to

Install

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

handful commands

pm2 list
pm2 log

+---------------------------------------+

[PM2] Freeze a process list on reboot via:

pm2 save

[PM2] Remove init script via:

pm2 unstartup systemd

+---------------------------------------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment