Vscode-ruby: Feature request: Debug multiple Ruby processes at once

Created on 11 Mar 2017  路  11Comments  路  Source: rubyide/vscode-ruby

Your environment

  • vscode-ruby version:
  • Ruby version:
  • VS Code version:
  • Operating System:
  • Hardware (optional):

Make sure you have ruby, ruby-debug-ide and ruby-debug-basex19 installed before submitting your issue -- thank you !

Expected behavior

I should be able to launch multiple Ruby debug processes at once, e.g. we'd like to be able to debug Rails, Sidekiq and ActionCable.

If I get a few spare minutes in the next few weeks, I may open a pull request to do this.

Actual behavior

The Ruby-Debug-IDE is always connecting to port 1234, so launching more than one Ruby process with the debugger fails.

Steps to reproduce the problem

Try to debug multiple Ruby processes at once.

I'm new to Visual Studio Code, so I'll see if I can figure out how to add this feature to the extension in the next few weeks :)

feature-request

Most helpful comment

@senhalil, @QMuncaster: you can configure two distinct "debuggerPort"s.

Here is a working launch.json (provided you started a Redis server first for Sidekiq):

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Server",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server"
            ],
            "debuggerPort": "1234"
        },
        {
            "name": "Sidekiq",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/sidekiq",
            "args": [
                "-C",
                "${workspaceRoot}/config/sidekiq.yml"
            ],
            "debuggerPort": "1235"
        }
    ],
    "compounds": [
        {
            "name": "Server + Sidekiq",
            "configurations": ["Server", "Sidekiq"]
        }
    ]
}

All 11 comments

+1

@ukblewis thanks for your feedback and this is a valid feature request. I'll say it is not too difficult to implement :) It consists of two parts

Let me know if you are still interested in contributing to it :) Previously this project is kind of dead as I'm busy with other stuff but now I'll spend time on it every week if possible.

Hi @rebornix ,

I've made some attempt to start this - see my open pull request that let's you manually assign ports. But I'm struggling to get the tests to pass - it seems like it's not related to my code - so if you could help with that, that'd be awesome! :)

Thank you!

@ukblewis I left comments in your PR and they are real easy fix :) It looks good to me, I'll merge it once you update.

Thank you @rebornix :) Super excited to try this out!

Where's the PR? On what version will this be out?

PR #148 fixes an issue I encountered after my original PR that added this feature. It is merged into master, it's just a matter of when @rebornix decides to trigger a new release.

Hi @benglewis I am trying to debug an application with two processes (a server and a worker). I am using the following launch.json file (as explained in the link @rebornix gave in https://github.com/rubyide/vscode-ruby/issues/126#issuecomment-294389328)

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Workers",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "/home/username/.rbenv/versions/2.1.8/bin/rake",
            "useBundler": true,
            "env": {
                "COUNT": "5",
                "QUEUE": "*"
            },
            "args": ["resque:workers"]
        },
        {
            "name": "Server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "/home/username/.rbenv/versions/2.1.8/bin/rake",
            "useBundler": true,
            "args": ["server"]
        }
    ],

    "compounds": [
        {
            "name": "Server/Workers",
            "configurations": ["Server", "Workers"]
        }
    ]
}

However, I get the following error (either in Server side or Worker side) when I run the Server/Workers compound config:

Fatal exception in DebugThread loop: Address already in use - bind(2) for "127.0.0.1" port 1234

Do I do something incorrectly?

@senhalil were you able to figure this out? Also getting the same issue.

@QMuncaster nope. Shortly after my message, I stopped trying to use vscode for debugging and started using byebug

@senhalil, @QMuncaster: you can configure two distinct "debuggerPort"s.

Here is a working launch.json (provided you started a Redis server first for Sidekiq):

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Server",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server"
            ],
            "debuggerPort": "1234"
        },
        {
            "name": "Sidekiq",
            "type": "Ruby",
            "request": "launch",
            "program": "${workspaceRoot}/bin/sidekiq",
            "args": [
                "-C",
                "${workspaceRoot}/config/sidekiq.yml"
            ],
            "debuggerPort": "1235"
        }
    ],
    "compounds": [
        {
            "name": "Server + Sidekiq",
            "configurations": ["Server", "Sidekiq"]
        }
    ]
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisnicola picture chrisnicola  路  5Comments

rebornix picture rebornix  路  3Comments

Snake-Sanders picture Snake-Sanders  路  4Comments

resistorsoftware picture resistorsoftware  路  3Comments

wingrunr21 picture wingrunr21  路  4Comments