我有简单的后台作业,使用resque-pool运行,这使得某些socksproxy调用。当我在Rails开发模式下启动resque-pool时,只要我更改为生产模式,我就可以使用后台作业点击连接超时
在
中执行时,相同的代码可以正常工作调用类似于:
req = Net::HTTP::Get.new(uri.request_uri)
response = Net::HTTP.SOCKSProxy(@socks_server, @socks_port).start(uri.host, uri.port) do |http|
http.request(req)
end
调查:
此调用发生在net/http.rb
TCPSocket.open(conn_address, conn_port, @local_host, @local_port)
我发现在生产模式中工作者子进程而不是加载
TCPSocket
来自socksify-1.7.0/lib/socksify.rb
的{{1}}类,它仍然来自提供resolv-replace.rb
的红宝石。不知道为什么会这样。
我看到错误:
连接超时 - 连接(2)for"" 6455端口: /usr/lib/ruby/gems/2.1.0/gems/socksify-1.7.0/lib/socksify.rb:178:in
initialize' /usr/lib/ruby/gems/2.1.0/gems/socksify-1.7.0/lib/socksify.rb:178:in
初始化' /usr/lib/ruby/2.1.0/resolv-replace.rb:23:ininitialize' /usr/lib/ruby/2.1.0/net/http.rb:879:in
打开' /usr/lib/ruby/2.1.0/net/http.rb:879:inblock in connect' /usr/lib/ruby/2.1.0/timeout.rb:76:in
超时' /usr/lib/ruby/2.1.0/net/http.rb:878:inconnect' /usr/lib/ruby/2.1.0/net/http.rb:863:in
do_start' /usr/lib/ruby/2.1.0/net/http.rb:852:instart' /usr/lib/ruby/2.1.0/net/http.rb:583:in
开始' /usr/lib/ruby/gems/2.1.0/gems/retries-0.0.5/lib/retries.rb:46:incall' /usr/lib/ruby/gems/2.1.0/gems/retries-0.0.5/lib/retries.rb:46:in
with_retries' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:177:inblock (3 levels) in perform' /usr/lib/ruby/gems/2.1.0/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/resque.rb:41:in
阻止在around_perform_with_monitoring' /usr/lib/ruby/gems/2.1.0/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:363:in `perform_action_with_newrelic_trace'/usr/lib/ruby/gems/2.1.0/gems/newrelic_rpm-3.16.2.321/lib/new_relic/agent/instrumentation/resque.rb:33:in
around_perform_with_monitoring' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:176:in
阻止(2级)执行' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:172:incall' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:172:in
阻止(3级)执行' ../app/jobs/resque_hooks.rb:15:inaround_perform_job_duration' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:172:in
阻止(2级)执行' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:184:incall' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/job.rb:184:in
执行' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/worker.rb:290:inperform' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/worker.rb:229:in
阻止工作' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/worker.rb:206:inloop' /usr/lib/ruby/gems/2.1.0/gems/resque-1.26.0/lib/resque/worker.rb:206:in
的工作' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:396:inblock in spawn_worker!' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:389:in
叉' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:389:in spawn_missing_workers_for中的spawn_worker!' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:367:in
阻止' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:366:intimes' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:366:in
spawn_missing_workers_for' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:352:inblock in maintain_worker_count' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:350:in
各' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:350:inmaintain_worker_count' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:263:in
开始' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool.rb:89:inrun' /usr/lib/ruby/gems/2.1.0/gems/resque-pool-0.6.0/lib/resque/pool/tasks.rb:17:in
阻止(2级)' /usr/lib/ruby/gems/2.1.0/gems/rake-11.2.2/lib/rake/task.rb:248:incall' /usr/lib/ruby/gems/2.1.0/gems/rake-11.2.2/lib/rake/task.rb:248:in
阻止执行' /usr/lib/ruby/gems/2.1.0/gems/rake-11.2.2/lib/rake/task.rb:243:ineach' /usr/lib/ruby/gems/2.1.0/gems/rake-11.2.2/lib/rake/task.rb:243:in
执行' /usr/lib/ruby/gems/2.1.0/gems/airbrake-5.5.0/lib/airbrake/rake/task_ext.rb:19:in {* 1}}阻止invoke_with_call_chain' /usr/lib/ruby/2.1.0/monitor.rb:211:inexecute' /usr/lib/ruby/gems/2.1.0/gems/rake-11.2.2/lib/rake/task.rb:187:in
invoke_with_call_chain
答案 0 :(得分:0)
经过更多调查后,由于在生产模式下启用了newrelic gem,因此转向了它。 newrelic需要resolv-replace
这与socksify gem和resque后台工作并不顺利。由于我不再需要新的遗物,只需禁用它我就能克服这个问题。