Attach ruby-debug-ide to existing Rails server

2k views Asked by At

Background

I have ruby-debug-ide all setup to remote debug (I'm using Docker) in Visual Studio Code. I am using this command in my docker-compose.yml to start ruby-debug-ide and my rails server:

rm -f /api/tmp/pids/server.pid && rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails server --port=3000 --binding=0.0.0.0

and then in vscode I have this launch.json script:

{
  "name": "Listen for rdebug-ide",
  "type": "Ruby",
  "request": "attach",
  "cwd": "${workspaceRoot}",
  "remoteHost": "127.0.0.1",
  "remotePort": "1234",
  "remoteWorkspaceRoot": "/app",
  "showDebuggerOutput": true
}

and when I go to vscode and start that launch.json script, my rails server starts up as well as the debugger. But when I stop/detach the launch.json script, the rails server dies.

My Question

Is there a way to start my Rails server and ruby-debug-ide independently? I want to be able to access my Rails application when I am not debugging. Is it possible to do something like this:

# start my rails server
rm -f /api/tmp/pids/server.pid && bin/rails server --port=3000 --binding=0.0.0.0

# also start rdebug-ide and wait for something (vscode) to attach to it later on
rdebug-ide --host 0.0.0.0 --port 1234 -- <attach_to_my_rails_server>
1

There are 1 answers

1
Nezir On

Did you tried this: rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails s -b 0.0.0.0