我通过工头启动独角兽,因此吞下了调试器提示符。我过去曾debugger
宝石幸运connecting as a remote debugger。
我们即将升级到Ruby 2.1.2,据我所知,它与debugger
不兼容。
我已将远程调试器代码更改为使用byebug
:
require 'byebug'
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}"
Byebug.start_server('localhost', port)
一旦启动了独角兽,我可以连接到byebug:
$ byebug -R localhost:54623
Connecting to byebug server localhost:54623
Connected.
但我的代码中充斥着byebug
次调用,并且它们永远不会在远程调试器中触发断点。远程连接时,调试器未正常远程加载时阻塞的页面。
unicorn文件只指定一个工作者,所以我有理由相信它不是它:
require File.dirname(__FILE__)+'/application'
if Rails.env.development?
worker_processes 1
timeout_override = ENV['WEBSERVER_TIMEOUT_OVERRIDE']
timeout Integer(timeout_override || 3600)
if timeout_override
puts "Development: Using WEBSERVER_TIMEOUT_OVERRIDE of #{timeout_override} seconds"
end
else
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout 25
end
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end
非常感谢任何想法。
答案 0 :(得分:1)
我认为你错过了一个简单的设置:
Byebug.wait_connection = true
更改此
port = find_available_port
puts "Remote debugger on port #{port}"
Byebug.start_server('localhost', port)
到这个
port = find_available_port
puts "Remote debugger on port #{port}"
Byebug.wait_connection = true
Byebug.start_server('localhost', port)
这应该是神奇的。希望它有所帮助。