How to manually run a Sidekiq job

Jay Godse picture Jay Godse · Feb 25, 2015 · Viewed 11.7k times · Source

I have an application which uses Sidekiq. The web server process will sometimes put a job on Sidekiq, but I won't necessarily have the worker running. Is there a utility which I could call from the Rails console which would pull one job off the Redis queue and run the appropriate Sidekiq worker?

Answer

jhnatr picture jhnatr · Jan 3, 2019

Here's a way that you'll likely need to modify to get the job you want (maybe like g8M suggests above), but it should do the trick:

> job = Sidekiq::Queue.new("your_queue").first
> job.klass.constantize.new.perform(*job.args)

If you want to delete the job:

> job.delete

Tested on sidekiq 5.2.3.