HelloWorld
HelloWorld

Reputation: 4349

How to check if sidekiq is started?

I am using the Sidekiq Gem with Rails 3. Is there a way to see if the sidekiq workers are ready to process jobs? We want to make sure that stuff is not just getting enqueued and sitting there. I tried something like this...

stats = Sidekiq::Stats.new
puts stats.queues

But that will always return default => 0, if redis is up, even if sidekiq is not ready to process jobs.

Upvotes: 10

Views: 11228

Answers (3)

pokrovskyy
pokrovskyy

Reputation: 487

First of all, your worker processes should be running. Check this:

ps = Sidekiq::ProcessSet.new
ps.size # => 2
ps.each do |process|
  p process['busy']     # => 3
  p process['hostname'] # => 'myhost.local'
  p process['pid']      # => 16131
end
ps.each(&:quiet!) # equivalent to the USR1 signal
ps.each(&:stop!) # equivalent to the TERM signal

From https://github.com/mperham/sidekiq/wiki/API#processes

So if they do - you can enqueue more work. The only case when tasks can remain in the queue while your worker processes are working is when the worker processes are processing jobs slower than they come in. Then your queue will grow and newly enqueued tasks will not be processed until all previous jobs are done. But this is your responsibility to figure out why your workers performing slowly.

Hope that helps!

Upvotes: 5

craig.kaminsky
craig.kaminsky

Reputation: 5598

For myself, I prefer to run the following in a console (either on my server or locally):

ps -ef | grep "sidekiq"

Upvotes: 3

Winfield
Winfield

Reputation: 19145

You can access the Sidekiq Workers API to access the active set of workers:

worker_api = Sidekiq::Workers.new
worker_api.size
 => 1
worker_api.each {|worker| do_stuf(worker) }

The simplest solution would be to access the API and wait until the expected number of worker processes are up and running via the size attribute of the Worker API.

Upvotes: 5

Related Questions