我正在使用 Rails 4.2。我使用工头启动 Rails,我想在启动 Rails 时附加一个调试器。这个问题详细介绍了 Rails 3.2 的过程——如何调试由工头启动的 rails (3.2) 应用程序?,但是我相信这个文件已经过时了
$ cat config/initializers/start_debugger.rb
# Enabled debugger with foreman, see https://github.com/ddollar/foreman/issues/58
if Rails.env.development?
require 'debugger'
Debugger.wait_connection = true
def find_available_port
server = TCPServer.new(nil, 0)
server.addr[1]
ensure
server.close if server
end
port = find_available_port
puts "Remote debugger on port #{port}"
Debugger.start_remote(nil, port)
end
因为我不认为 Rails 4.2 支持“调试器”gem。如何在使用 Rails 4.2 的专用调试端口上使用工头启动 Rails?