Pm2: node_args are not passed to the node with pm2-docker

Created on 4 Nov 2017  ยท  9Comments  ยท  Source: Unitech/pm2

I'm trying to enable remote debugging on my container but docker-pm2 is not passing the interpreter args to the interpreter:

/app # pm2 show ux
 Describing process with id 0 - name ux
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ status            โ”‚ online                   โ”‚
โ”‚ name              โ”‚ ux                       โ”‚
โ”‚ restarts          โ”‚ 0                        โ”‚
โ”‚ uptime            โ”‚ 6m                       โ”‚
โ”‚ script path       โ”‚ /opt/ux/index.js         โ”‚
โ”‚ script args       โ”‚ N/A                      โ”‚
โ”‚ error log path    โ”‚ /dev/stderr              โ”‚
โ”‚ out log path      โ”‚ /dev/stdout              โ”‚
โ”‚ pid path          โ”‚ /tmp/ux_pm2-0.pid        โ”‚
โ”‚ interpreter       โ”‚ node                     โ”‚
โ”‚ interpreter args  โ”‚ --inspect                โ”‚ --debug=5859 โ”‚
โ”‚ script id         โ”‚ 0                        โ”‚
โ”‚ exec cwd          โ”‚ /app                     โ”‚
โ”‚ exec mode         โ”‚ cluster_mode             โ”‚
โ”‚ node.js version   โ”‚ 9.0.0                    โ”‚
โ”‚ watch & reload    โ”‚ โœ˜                        โ”‚
โ”‚ unstable restarts โ”‚ 0                        โ”‚
โ”‚ created at        โ”‚ 2017-11-04T16:31:14.627Z โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 Code metrics value
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Loop delay โ”‚ 27.81ms โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 Add your own code metrics: http://bit.ly/code-metrics
 Use `pm2 logs ux [--lines 1000]` to display logs
 Use `pm2 monit` to monitor CPU and Memory usage ux
/app # pm2 monit
/app # ps
PID   USER     TIME   COMMAND
    1 root       0:01 node /usr/local/bin/pm2-docker start /opt/pm2.json
   22 root       0:01 PM2 v2.7.2: God Daemon (/root/.pm2)
   28 root       0:04 node /opt/ux/index.js
   48 root       0:00 /bin/sh
   84 root       0:00 ps

as you can see on the output of ps, node is not getting the extra args.

Pending Release Docker

Most helpful comment

I'm trying to use docker to create a cross platform local dev environment and this prevents me from using it for debugging.

All 9 comments

I'm trying to use docker to create a cross platform local dev environment and this prevents me from using it for debugging.

hi, any news about this?

Hi, I've investigated this issue a bit more and the problem doesn't seem to be exclusive to pm2-docker, I'm using the same docker container image (keymetrics/pm2 latest 695685bbe71b 2 days ago 89.8MB) but I've overdid the docke command to use pm2 instead of pm2-docker (CMD [ "pm2", "start", "--no-daemon", "/opt/pm2.json" ]
) and I see the same issue there:

/app # ps faux
PID   USER     TIME   COMMAND
    1 root       0:01 node /usr/local/bin/pm2 start --no-daemon /opt/pm2.json
   23 root       0:06 node /opt/ux/index.js
   53 root       0:00 /bin/sh
   59 root       0:00 ps faux
/app # pm2 --version
2.8.0
/app # pm2-docker --version
2.8.0
/app # cat /opt/pm2.json
{
  "apps": [{
    "name": "ux",
    "script": "/opt/ux/index.js",
    "log_date_format": "YYYY-MM-DD HH:mm Z",
    "pid_file": "/tmp/ux_pm2.pid",
    "error_file": "/dev/stderr",
    "out_file": "/dev/stdout",
    "instances": 1,
    "node_args": ["--inspect", "--debug=5859"],
    "exec_mode": "cluster"
  }]
}
/app # pm2 show ux
 Describing process with id 0 - name ux
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ status            โ”‚ online                   โ”‚
โ”‚ name              โ”‚ ux                       โ”‚
โ”‚ restarts          โ”‚ 0                        โ”‚
โ”‚ uptime            โ”‚ 2m                       โ”‚
โ”‚ script path       โ”‚ /opt/ux/index.js         โ”‚
โ”‚ script args       โ”‚ N/A                      โ”‚
โ”‚ error log path    โ”‚ /dev/stderr              โ”‚
โ”‚ out log path      โ”‚ /dev/stdout              โ”‚
โ”‚ pid path          โ”‚ /tmp/ux_pm2-0.pid        โ”‚
โ”‚ interpreter       โ”‚ node                     โ”‚
โ”‚ interpreter args  โ”‚ --inspect                โ”‚ --debug=5859 โ”‚
โ”‚ script id         โ”‚ 0                        โ”‚
โ”‚ exec cwd          โ”‚ /app                     โ”‚
โ”‚ exec mode         โ”‚ cluster_mode             โ”‚
โ”‚ node.js version   โ”‚ 9.2.0                    โ”‚
โ”‚ watch & reload    โ”‚ โœ˜                        โ”‚
โ”‚ unstable restarts โ”‚ 0                        โ”‚
โ”‚ created at        โ”‚ 2017-12-05T13:09:54.101Z โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 Code metrics value
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Loop delay โ”‚ 123.36ms โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 Add your own code metrics: http://bit.ly/code-metrics
 Use `pm2 logs ux [--lines 1000]` to display logs
 Use `pm2 monit` to monitor CPU and Memory usage ux

this seems to be working with PM2 version 2.7.2 without docker.

@vmarchaud maybe we should update the issue title since this is not affecting pm2-docker only.

tested with "exec_mode": "fork" and I still have the same issue:

{
  "apps": [{
    "name": "ux",
    "script": "/opt/ux/index.js",
    "log_date_format": "YYYY-MM-DD HH:mm Z",
    "pid_file": "/tmp/ux_pm2.pid",
    "error_file": "/dev/stderr",
    "out_file": "/dev/stdout",
    "instances": 1,
    "node_args": ["--inspect", "--debug=5859"],
    "exec_mode": "fork"
  }]
}

this worked for me with node8:

instances: 1
exec_mode: fork
node_args: [ "--inspect=0.0.0.0:9229" ]

of course, you also need to open port 9229 on the container (-p 9229:9229)

pending release

PM2 2.10.1 has been release:

$ npm install pm2@latest -g
$ pm2 update
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexpts picture alexpts  ยท  3Comments

liujb picture liujb  ยท  3Comments

jubairsaidi picture jubairsaidi  ยท  3Comments

getvega picture getvega  ยท  3Comments

ghost picture ghost  ยท  3Comments