OSDN Git Service

Regular updates
[twpd/master.git] / pm2.md
1 ---
2 title: pm2
3 category: CLI
4 layout: 2017/sheet
5 authors: { github: "Dr-Dino" }
6 updated: 2020-05-08
7 ---
8
9 ### Fork mode
10
11 | Command                          | Description              |
12 | ---                              | ---                      |
13 | `pm2 start app.js --name my-api` | Start and name a process |
14
15 ### Cluster mode
16
17 | Command                 | Description                                                        |
18 | ---                     | ---                                                                |
19 | `pm2 start app.js -i 0` | Will start maximum processes with LB depending on available CPUs     |
20
21 ### Listing
22
23 | Command          | Description                                         |
24 | ---              | ---                                                 |
25 | `pm2 list`       | Display all processes status                        |
26 | `pm2 jlist`      | Print process list in raw JSON                      |
27 | `pm2 prettylist` | Print process list in beautified JSON               |
28 | ---              | ---                                                 |
29 | `pm2 describe 0` | Display all information about a specific process    |
30 | ---              | ---                                                 |
31 | `pm2 monit`      | Monitor all processes                               |
32
33 ### Logs
34
35 | Command            | Description                               |
36 | ---                | ---                                       |
37 | `pm2 logs [--raw]` | Display all processes logs in streaming   |
38 | `pm2 flush`        | Empty all log files                       |
39 | `pm2 reloadLogs`       | Reload all logs                           |
40
41 ### Actions
42
43 | Command           | Description                                    |
44 | ---               | ---                                            |
45 | `pm2 stop all`    | Stop all processes                             |
46 | `pm2 restart all` | Restart all processes                          |
47 | ---               | ---                                            |
48 | `pm2 reload all`  | Will 0s downtime reload (for NETWORKED apps)       |
49 | ---               | ---                                            |
50 | `pm2 stop 0`      | Stop specific process id                       |
51 | `pm2 restart 0`   | Restart specific process id                    |
52 | ---               | ---                                            |
53 | `pm2 delete 0`    | Will remove process from pm2 list              |
54 | `pm2 delete all`  | Will remove all processes from pm2 list        |
55 | ---               | ---                                            |
56 | `pm2 save`        | Save processes list to respawn at reboot       |
57
58 ### Misc
59
60 | Command                             | Description                                                    |
61 | ---                                 | ---                                                            |
62 | `pm2 reset <process>`               | Reset meta data (restarted time...)                            |
63 | `pm2 updatePM2`                     | Update in memory pm2                                           |
64 | `pm2 ping`                          | Ensure pm2 daemon has been launched                            |
65 | `pm2 sendSignal SIGUSR2 my-app`     | Send system signal to script                                   |
66 | ---                                 | ---                                                            |
67 | `pm2 start app.js --no-daemon`      | Run pm2 daemon in the foreground if it doesn't exist already     |
68 | `pm2 start app.js --no-vizion`      | Skip vizion features (versioning control)                      |
69 | `pm2 start app.js --no-autorestart` | Do not automatically restart app                               |