Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to find a job anywhere in Sidekiq

Is there an easy way to search through all of sidekiq (queues, retries, schedules, etc) for a specific job?

Currently I'm doing this:

if !Sidekiq::Queue.new("feeds").find {|j| j.args[0] == feed.id && j.args[1] == true }
  if !Sidekiq::RetrySet.new.find {|j| j.queue == 'feeds' && j.args[0] == feed.id && j.args[1] == true }
    if !Sidekiq::ScheduledSet.new.find {|j| j.queue == 'feeds' && j.args[0] == feed.id && j.args[1] == true }
      feed.sync
    end
  end
end

But given how large queues can get, there's a chance the job could move between sets during the iteration and get missed.

like image 685
farski Avatar asked Jun 14 '13 13:06

farski


People also ask

How does Sidekiq queue work?

Sidekiq server process pulls jobs from the queue in Redis and processes them. Like your web processes, Sidekiq boots Rails so your jobs and workers have the full Rails API, including Active Record, available for use. The server will instantiate the worker and call perform with the given arguments.

When should I use Sidekiq?

You can just use direct Sidekiq jobs when you need the improved performance and bulk-enqueing. If your workload is light, or you are early on in your project, you might not need Sidekiq (or at least its Redis dependancy) at all.

How do I manually run a Sidekiq job?

To run sidekiq, you will need to open a terminal, navigate to your application's directory, and start the sidekiq process, exactly as you would start a web server for the application itself. When the command executes you will see a message that sidekiq has started.

How do I test my Sidekiq workers?

To test your Sidekiq Worker jobs array, run WorkerNameHere.jobs in terminal and see if it contains your job with your jid. If it does, then it was enqueued in Sidekiq to be run as a job.

How many employees does Sidekiq have?

Each node runs 8 sidekiq worker processes. Each sidekiq worker process has a concurrency of 15, meaning that 15 sidekiq jobs can be processed in parallel.


1 Answers

Seems like you want to know your job's status at some moment after spawning it, also you keep its id. There are a couple of plugins exactly for that, they have similar functionality and virtually the same name:

Sidekiq::Status - I was its original author, now it's supported by more apt Ruby developers

SidekiqStatus - an alternative

[edit] the above may be outdated by now, just check Sidekiq's wiki to find queue/status management that suits you best: https://github.com/mperham/sidekiq/wiki/Related-Projects

like image 189
Utgarda Avatar answered Oct 05 '22 00:10

Utgarda