Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node_args are not passed to the node with pm2-docker #3257

Closed
vmarchaud opened this issue Nov 4, 2017 · 11 comments
Closed

node_args are not passed to the node with pm2-docker #3257

vmarchaud opened this issue Nov 4, 2017 · 11 comments

Comments

@vmarchaud
Copy link
Contributor

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.

@luisdavim
Copy link

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

@luisdavim
Copy link

hi, any news about this?

@luisdavim
Copy link

luisdavim commented Dec 5, 2017

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

@luisdavim
Copy link

luisdavim commented Dec 5, 2017

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

@luisdavim
Copy link

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

@luisdavim
Copy link

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"
  }]
}

@nagy-tamas
Copy link

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)

@Unitech
Copy link
Owner

Unitech commented Feb 2, 2018

pending release

@wallet77
Copy link
Contributor

PM2 2.10.1 has been release:

$ npm install pm2@latest -g
$ pm2 update

@ManfredHu
Copy link

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)

Do you know why this configuration takes effect?

@nagy-tamas
Copy link

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)

Do you know why this configuration takes effect?

As far as I remember (it was a very long time ago) 127.0.0.1 was the default inspect target, so you could only connect to node with a debugger if your debugger run inside the very same Docker container the Node also runs, which is of course usually not the case.
0.0.0.0 tells Node to accept debugger connections from the outside, in our case the host computer, which is your main OS, where Docker runs. Most likely this is where your dev environment also runs, with your debugger.

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

No branches or pull requests

6 participants