Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show pm2 command that started a process

Tags:

node.js

pm2

From my linux machine, typing pm2 status shows me

│ App name     │ id │ mode │ pid   │ status  │ restart │ uptime │ memory      │ watching │
├──────────────┼────┼──────┼───────┼─────────┼─────────┼────────┼─────────────┼──────────┤
│ gamatrix-dev │ 0  │ fork │ 0     │ stopped │ 0       │ 0      │ 0 B         │ disabled │
│ gamatrix     │ 1  │ fork │ 22779 │ online  │ 10      │ 2D     │ 78.793 MB   │ disabled │
│ elevacad     │ 2  │ fork │ 14106 │ online  │ 13      │ 3D     │ 36.227 MB   │ disabled │

I'm pretty sure for the last two lines, they were initiated by a command like pm2 start someapp.js. Is there a way to know what value someapp.js really was that started the process?

like image 813
John Avatar asked Oct 03 '15 15:10

John


1 Answers

As mentioned in a comment, use

pm2 describe

That will produce copious output similar to the following:

┌───────────────────┬─────────────────────────────────────────────────────────────────────────────────────┐
│ status            │ online                                                                              │
│ name              │ random                                                                              │
│ namespace         │ default                                                                             │
│ version           │ 1.0.0                                                                               │
│ restarts          │ 0                                                                                   │
│ uptime            │ 107m                                                                                │
│ script path       │ /home/pi/checkout/random-monitor.ts                                                 │
│ script args       │ N/A                                                                                 │
│ error log path    │ /home/pi/.pm2/logs/random-error.log                                                 │
│ out log path      │ /home/pi/.pm2/logs/random-out.log                                                   │
│ pid path          │ /home/pi/.pm2/pids/random-1.pid                                                     │
│ interpreter       │ /home/pi/.nvm/versions/node/v12.19.0/lib/node_modules/pm2/node_modules/.bin/ts-node │
│ interpreter args  │ N/A                                                                                 │
│ script id         │ 1                                                                                   │
│ exec cwd          │ /home/pi/checkout                                                                   │
│ exec mode         │ fork_mode                                                                           │
│ node.js version   │ 12.19.0                                                                             │
│ node env          │ N/A                                                                                 │
│ watch & reload    │ ✘                                                                                   │
│ unstable restarts │ 0                                                                                   │
│ created at        │ 2020-11-18T00:17:04.623Z                                                            │
└───────────────────┴─────────────────────────────────────────────────────────────────────────────────────┘

The interpreter, interpreter args, script path and script args should give you what you are after. See also this answer to a similar question.

like image 176
John Cummings Avatar answered Mar 18 '23 17:03

John Cummings