代码之家  ›  专栏  ›  技术社区  ›  Vi.

使用RubyMine在Kubernetes上远程调试Rails应用程序

  •  0
  • Vi.  · 技术社区  · 4 年前

    我正在调试在k8s集群中运行的rails应用程序。

    使用的堆栈如下: Ruby '2.6.6' - Docker Engine v20.10.2 - Kubernetes v1.19.3 - Skaffold v1.17.2 - MacOS BigSur 11.1

    Skaffold正在跑步 skaffold dev --port-forward

    在Dockerfile中,我有 CMD ["rdebug-ide", "--debug", "--host", "0.0.0.0", "--port", "1234", "--dispatcher-port", "5884", "--", "bin/bundle", "exec", "rails", "s"]

    此应用程序的服务yaml如下:

    apiVersion: v1
    kind: Service
    metadata:
      name: system-management-srv
    spec:
      selector:
        app: system-management
      ports:
        - name: system-management
          port: 3000
        - name: debug
          port: 1234
    

    enter image description here

    当我启动“RemoteDebug”配置时,它可以检测断点,但输出错误为:

    [system-management] Connected from local client
    [system-management] 1: Starting control thread
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:25
    [system-management] 1: <breakpointAdded no="1" location="/project/app/controllers/api/v1/services_controller.rb:25"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:28
    [system-management] 1: <breakpointAdded no="2" location="/project/app/controllers/api/v1/services_controller.rb:28"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:29
    [system-management] 1: <breakpointAdded no="3" location="/project/app/controllers/api/v1/services_controller.rb:29"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:27
    [system-management] 1: <breakpointAdded no="4" location="/project/app/controllers/api/v1/services_controller.rb:27"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:7
    [system-management] 1: <breakpointAdded no="5" location="/project/app/controllers/api/v1/services_controller.rb:7"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:24
    [system-management] 1: <breakpointAdded no="6" location="/project/app/controllers/api/v1/services_controller.rb:24"/>
    [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:11
    [system-management] 1: <breakpointAdded no="7" location="/project/app/controllers/api/v1/services_controller.rb:11"/>
    [system-management] 1: Processing in control: start
    [system-management] 1: Starting: running program script
    [system-management] /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide/multiprocess/starter.rb:3:in `<top (required)>': undefined method `split' for nil:NilClass (NoMethodError)
    [system-management]     from bin/rails:1:in `require'
    [system-management] Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
    WARN[3324] exit status 1                                
    [system-management] error: unexpected EOF
    

    我怎样才能让它工作?

    编辑:

    我尝试添加

    ENV DEBUGGER_STORED_RUBYLIB ''
    ENV RUBYLIB ''
    

    如所建议的 here ,但仍面临错误

        [system-management] 1: Processing in control: b /project/app/controllers/api/v1/services_controller.rb:11
        [system-management] 1: <breakpointAdded no="7" location="/project/app/controllers/api/v1/services_controller.rb:11"/>
        [system-management] 1: Processing in control: start
        [system-management] 1: Starting: running program script
        [system-management] 1: connection failed(1)
        [system-management] Exception: Connection refused - connect(2) for "127.0.0.1" port 5884
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:201:in `initialize'
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:201:in `open'
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:201:in `block in notify_dispatcher_if_needed'
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:199:in `times'
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:199:in `notify_dispatcher_if_needed'
        [system-management]     /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:146:in `block in _start_control_common'
    [system-management] Fatal exception in DebugThread loop: undefined method `accept' for 3:Integer
    [system-management] Backtrace:
    [system-management] /usr/local/bundle/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:160:in `block in _start_control_common'
    [system-management] Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 0.0.0.0:1234
    
    0 回复  |  直到 4 年前