Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manually run a Sidekiq job

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?

like image 986
Jay Godse Avatar asked Feb 25 '15 16:02

Jay Godse


People also ask

How can I test my Sidekiq worker locally?

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 does a Sidekiq job stop running?

In order to restart a Sidekiq worker, the recommended way is to send SIGTERM, which is the signal sent to a process to request its termination, to the worker process with a pre-defined timeout configured, followed by the spawning of a new process.

How do I run Sidekiq on Ubuntu?

Make sure you have given the correct path of your bundler for ExecStart in order to start the process. Save it as sidekiq. service and run systemctl enable sidekiq . Then we can manage the process using the commands systemctl start sidekiq , systemctl stop sidekiq , and systemctl restart sidekiq .


1 Answers

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.

like image 74
jhnatr Avatar answered Sep 17 '22 13:09

jhnatr