Sidekiq:计算可用线程数

时间:2016-07-19 22:21:59

标签: ruby-on-rails ruby sidekiq

我想从Rails控制台计算可用的Sidekiq线程/处理器的总数。

threads != workers

Sidekiq::Workers.size doesn't work

1 个答案:

答案 0 :(得分:3)

您正在寻找Sidekiq::ProcessSet#each

https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/api.rb#L719

Sidekiq::ProcessSet.new.each do |pro| 
  puts "I have #{pro['concurrency'] - pro['busy']} threads free"
end