将 ruby​​-debug-ide 连接到现有的 Rails 服务器

jam*_*mes 5 ruby ruby-on-rails ruby-debug-ide visual-studio-code vscode-debugger

背景

我已ruby-debug-ide在 Visual Studio Code 中完成远程调试(我正在使用 Docker)的所有设置。docker-compose.yml我在启动ruby-debug-ide和 Rails 服务器中使用此命令:

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
Run Code Online (Sandbox Code Playgroud)

然后在 vscode 中我有这个 launch.json 脚本:

{
  "name": "Listen for rdebug-ide",
  "type": "Ruby",
  "request": "attach",
  "cwd": "${workspaceRoot}",
  "remoteHost": "127.0.0.1",
  "remotePort": "1234",
  "remoteWorkspaceRoot": "/app",
  "showDebuggerOutput": true
}
Run Code Online (Sandbox Code Playgroud)

当我转到 vscode 并启动 launch.json 脚本时,我的 Rails 服务器以及调试器都会启动。但是当我停止/分离 launch.json 脚本时,rails 服务器崩溃了。

我的问题

有没有办法独立启动我的 Rails 服务器ruby-debug-ide我希望在不进行调试时能够访问我的 Rails 应用程序。是否可以做这样的事情:

# 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>
Run Code Online (Sandbox Code Playgroud)

Nez*_*zir 0

你试过这个吗: rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails s -b 0.0.0.0