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

Can't set debug port by specifying --node-args="--debug=7001" #610

Closed
MeanwhileMedia opened this issue Aug 4, 2014 · 11 comments
Closed

Comments

@MeanwhileMedia
Copy link
Contributor

pm2 start main.js --node-args="--debug=7001"

When running the above cli command, the node process does receive the "--debug" argument, but ignores the port. The console responds:

Debugger listening on port 5863

I am assuming port #5863 is just a default selected by node. Any ideas why the port isn't getting set?

@soyuka
Copy link
Collaborator

soyuka commented Aug 4, 2014

From node man:

--debugger_port (Port to use for remote debugging)
               type: int  default: 5858

@MeanwhileMedia
Copy link
Contributor Author

Hi @soyuka. Yeah I saw the --debugger_port option via "node --v8-options". Unfortunately, that isn't setting the port either. Strangely, the command below succeeds, which is why I was thinking this issue might be pm2 related.

node --debug=7001 main.js

I'm running pm2 v0.9.5, and node v0.11.13

@soyuka
Copy link
Collaborator

soyuka commented Aug 4, 2014

I've just tested with a basic server and the --debug=7001 option, the debugger is active on 7001. I'm using node 10.26 (omg that's old \o/).

❯ pm2 start forks/pm2/test/fixtures/server.js  --node-args="--debug=7001"                    
{ online: true, success: true, pid: 16134, pm2_version: '0.9.5' }
debugger listening on port 7001

Just tested with 0.11.13 and indeed the option doesn't work anymore with pm2 but works without - weird. Maybe that's a cluster issue with 0.11.13?

@soyuka soyuka added bug labels Aug 4, 2014
@MeanwhileMedia
Copy link
Contributor Author

Thanks for verifying @soyuka - thought maybe I was going crazy. I haven't had time to check, but I'm wondering if this bug can be found in pm2-axon-rpc?

@soyuka
Copy link
Collaborator

soyuka commented Aug 4, 2014

But why would it work with 0.10.30 if it was?

@soyuka
Copy link
Collaborator

soyuka commented Aug 12, 2014

It's crazy but cluster execArgv --debug is replaced:

console.log(process.env.nodeArgs)
[harmony-0 (out) 2014-08-12T18:15:07] --harmony,--debug=7001
console.log(process.execArgv)
[harmony-0 (out) 2014-08-12T18:15:07] [ '--harmony', '--debug=5859' ]

I can't figure out why...

@Unitech
Copy link
Owner

Unitech commented Nov 13, 2014

Hope it will be fixed in Node 0.12

@Unitech Unitech closed this as completed Nov 13, 2014
@gbertoncelli
Copy link

gbertoncelli commented Nov 29, 2018

In your PM2 configuration file I think you have to use this parameters:
"node_args": ["--inspect=localhost:YOUR_PORT_NUMBER"]

@Shogobg
Copy link

Shogobg commented Jan 8, 2021

@HighSoftWare96 it's not working.

@lucrus73
Copy link

lucrus73 commented May 6, 2022

Same here, it's not working. I start my process with

# pm2 start process.json

and here are the contents of process.json

{
    "apps": [{
        "name": "myapp-debug",
        "script": "app.js",
        "watch": true,
        "exec_mode": "cluster",
        "cwd": "/srv/myapp/",
        "instances": 1,
        "merge_logs": true,
        "error_file": "/var/log/myapp/error.log",
        "out_file": "/var/log/myapp/out.log",
	"node_args": ["--inspect=127.0.0.1:9230","--inspect-port=9230"],
        "env": {
           "MONGODB": "mongodb://admin:secret@localhost:27017/mydb",
           "TIMEZONE": "+01:00",
        }
    }]
}

after starting it I get node listening on a different port (currently 9694, but it changes on every restart). I've already tried several variations such as specifying --inspect only, or leaving out the ip address, and the like, but it never listens on 9230.
I'm using pm2 version 5.2.0 and node version 14.19.

Running node --inspect=9230 app.js does work as expected with the debugger listening on port 9230.

@lucrus73
Copy link

lucrus73 commented May 6, 2022

Same here, it's not working.

Never mind, it now works. I don't know what I did to make it work (or what I was doing wrong), but it works.

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