Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Specify debug port per worker #5318

Description

@pavele

Hi,
Currently it looks impossible to debug worker processes. Here is a discussion related with node-inspector:
node-inspector/node-inspector#130

Is it possible to add ability to change the debug ports for the workers?

Thanks

Activity

  1. IvanTorresEdge commented on Apr 17, 2013

    @IvanTorresEdge

    I was also following issue #130 and none of the alternatives posted there works for us. Kind of frustrated around this, so +10

  2. chestone commented on Apr 19, 2013

    @chestone

    Having the same issue here and it is frustrating.

  3. bnoordhuis commented on Apr 20, 2013

    @bnoordhuis
    Member

    We'll address that in due time. The cluster module is scheduled for rework anyway. Until then, you can use something like this:

    var cluster = require('cluster');
    var http = require('http');
    
    if (cluster.isMaster) {
      var debug = process.execArgv.indexOf('--debug') !== -1;
      cluster.setupMaster({
        execArgv: process.execArgv.filter(function(s) { return s !== '--debug' })
      });
      for (var i = 0; i < 2; ++i) {
        if (debug) cluster.settings.execArgv.push('--debug=' + (5859 + i));
        cluster.fork();
        if (debug) cluster.settings.execArgv.pop();
      }
    }
    else {
      var server = http.createServer(function(req, res) {
        res.end('OK');
      });
      server.listen(8000);
    }

    It's improper use of the API (cluster.settings should be considered immutable) but this snippet works with v0.10.

  4. added a commit that references this issue on Aug 8, 2013
    b4de092
  5. added a commit that references this issue on Oct 24, 2013
    eb5a274
  6. added a commit that references this issue on Mar 17, 2014
    2b06b6b
  7. benfleis commented on May 5, 2014

    @benfleis

    @bnoordhuis @bajtos Any plans to backport the proper to v0.10 (including the -port command line arg)?

  8. indutny commented on May 5, 2014

    @indutny
    Member

    @benfleis that would be a behavior change, I think. This could be done only in unstable branches.

  9. benfleis commented on May 5, 2014

    @benfleis

    @indutny Makes sense. Thanks :)

  10. Redsandro commented on Sep 23, 2014

    @Redsandro

    I think a similar problem is happening when using child.fork() when the parent is already using --debug.

    Failed to open socket on port 5858, waiting 1000 ms before retrying

    I guess we can override this using arguments, but the documentation is not opening my eyes yet.

  11. Redsandro commented on Sep 23, 2014

    @Redsandro

    Workaround, something like this before you fork():

    var debugArgIdx = process.execArgv.indexOf('--debug');
    if (debugArgIdx !== -1) {
        // Remove debugging from forked process
        process.execArgv.splice(debugArgIdx, 1);
    }
    
  12. srlowe commented on Nov 6, 2014

    @srlowe

    In which version is this working properly?

  13. added a commit that references this issue on Jul 27, 2026
    43ec1b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions