【问题标题】:Attach ruby-debug-ide to existing Rails server将 ruby​​-debug-ide 附加到现有的 Rails 服务器
【发布时间】:2018-10-08 02:31:45
【问题描述】:

背景

我已将 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

然后在 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
}

当我转到 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>

【问题讨论】:

标签: ruby-on-rails ruby visual-studio-code vscode-debugger ruby-debug-ide


【解决方案1】:

您是否尝试过: rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails s -b 0.0.0.0

【讨论】:

  • 是的,那是我的第一次尝试。 rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails server --port=3000 --binding=0.0.0.0 然后我的 rails 应用程序在我附加调试器之前不会启动。
猜你喜欢
  • 2018-04-18
  • 1970-01-01
  • 2010-09-05
  • 2011-02-28
  • 2018-04-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多