Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sidekiq stop one single, running job

So I need to stop a running Job in Sidekiq (3.1.2) programmatically, not a scheduled one. I did read the API documentation but didn't really find anything about cancelling running jobs. Is this possible with sidekiq?

When this is not directly possible, my idea was to circumvent this, by raising an exception in the job when I call the signal, then deleting the job from the retryset. This is clearly not optimal though.

Thanks in advance

like image 701
Figedi Avatar asked Sep 17 '14 11:09

Figedi


People also ask

How do you kill a running job in Sidekiq?

Correct, the only way to stop a job is for the job to stop itself.

How many jobs can Sidekiq handle?

Sidekiq handles concurrency by using multiple threads in its process. This way, it can process multiple jobs at once, each thread processing one job at a time. By default, Sidekiq uses 10 threads per process. You can configure it to use more threads, thus increasing concurrency.

How do I stop Sidekiq?

The only consistent fix I've found is rebooting. kill 'process_id' worked fine, to kill the process. Though then restarting sidekiq it can't find redis. Moreover, 'kill -term pid' will cause it to shut down as gracefully as it can in the next 10 seconds.

Is Sidekiq concurrent?

Sidekiq's "concurrency" setting is just a setting of how many threads it will run at once. High numbers lead to more fragmentation. You could imagine that 1 thread uses log(x) memory over time, so increasing the number of threads leads to n * log(x) memory use.


1 Answers

Correct, the only way to stop a job is for the job to stop itself. Your application must implement that logic.

https://github.com/mperham/sidekiq/wiki/FAQ#how-do-i-cancel-a-sidekiq-job

like image 117
Mike Perham Avatar answered Nov 28 '22 03:11

Mike Perham