sonnyhe2002
sonnyhe2002

Reputation: 2121

how to check sidekiq status without an extension

On the sidekiq wiki it says I can check the status of sidekiq by polling it. I know when I perform delay method sidekiq will return the process id, but how do check Sidekiq to see if the id is finished processing.

I would expect some code like this:

if Sidekiq.check_complete?(process_id)
    puts 'Process completed'
end

I want to do this without any extra gems.

Upvotes: 1

Views: 5068

Answers (1)

blotto
blotto

Reputation: 3407

From your comment above, if you want to check if Sidekiq is done processing, the best approach is to check your queue size. For example, using some helper functions as below..

 def sidekiq_stats()
   summary = Hash.new
   stats = Sidekiq::Stats.new
   summary = { processed: stats.processed,
               failed: stats.failed,
              enqueued: stats.enqueued,
              queues: stats.queues}
end


def queue_stats(queue)
  summary = Hash.new
  queue = Sidekiq::Queue.new(queue)
  summary = { size: queue.size,
              latency: queue.latency}
end

You can call each queue and check the size, if all queues have size 0, the Sidekiq worker is idle.

Upvotes: 1

Related Questions