September 2018
Intermediate to advanced
764 pages
20h 6m
English
To see PM2 in action, we're going to kill our Node.js process manually, and see if PM2 will automatically restart it. We'll use the npx pm2 list command, which lists all processes in a static table:
hobnob@hobnob:$ npx pm2 list┌───────┬────┬───────┬────────┬───┬────────┬─────┬─────────┐│ Name │ id │ pid │ status │ ↺ │ uptime │ cpu │ mem │├───────┼────┼───────┼────────┼───┼────────┼─────┼─────────┤│ index │ 0 │ 15540 │ online │ 0 │ 20m │ 0% │ 40.8 MB │└───────┴────┴───────┴────────┴───┴────────┴─────┴─────────┘hobnob@hobnob:$ kill 15540hobnob@hobnob:$ npx pm2 list┌───────┬────┬───────┬────────┬───┬────────┬─────┬─────────┐│ Name │ id │ pid │ status │ ↺ │ uptime │ cpu │ mem │├───────┼────┼───────┼────────┼───┼────────┼─────┼─────────┤ ...
Read now
Unlock full access