2
votes

Saw lots of posts regarding the debugging of remote Node js server and tried a lot of their solutions yet did not manage to get my configuration to work

I have Intellij installed on a Windows PC with the following "Node.js Remote Debug" configuration: Host:my-server.dev.com Port:5858

the node server itself is installed on UBUNTU with the following port forwarding rule defined on it: socat TCP-LISTEN:5858,fork TCP:localhost:6000

and the server runs with the following command (cluster : /usr/local/n/versions/node/0.10.44/bin/node --debug=6000 /opt/play/play-server/main.js)

Intellij shows session as connected yet cannot break on break points

1

1 Answers

2
votes

Several steps were done to solve this issue: 1. start the script executor to use : "n use 0.10.44 --debug"
// (this is from my script)

forever \
      --pidFile $PIDFILE \
      -a \
      -l $LOGFILE \
      --minUptime $MIN_UPTIME \
      --spinSleepTime $SPIN_SLEEP_TIME \
      start -c "n use 0.10.44 --debug" $APPLICATION_PATH 2>&1 > /dev/null &
    RETVAL=$?
  1. create on the remote cluster a rule for forwarding (here to port 6000) socat TCP-LISTEN:5858,fork TCP:localhost:6000
  2. in your node server just before you fork :

    var debug = process.execArgv.indexOf('--debug') !== -1; if(debug) { //Set an unused port number. process.execArgv.push('--debug=' + (6000)); } var childProcess = cluster.fork();

This allows me to debug only one of the cluster processes using the same intellij configuration I set in the question