Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sidekiq won't shut down after Ctrl+C

I'm using Sidekiq for background operations of my Rails 4.1 app.

When I type Ctrl+C to shutdown Sidekiq, Sidekiq catches the signal but seems to freeze after this last log line:

^C2014-09-18T16:17:19.194Z 20686 TID-ovwtinh0g INFO: Shutting down
2014-09-18T16:17:21.041Z 20686 TID-ovwtixflc INFO: Shutting down 5 quiet workers

Thus, I need another terminal window where I need to type:

bundle exec sidekiqctl stop pidfile

This is really inconvenient (and takes about 8 seconds) and I can't find why Sidekiq won't stop properly with Ctrl+C.

My conf is:

  • Rails 4.1.5
  • Sidekiq 3.2.4
  • Postgresql DB
like image 497
Dirty Henry Avatar asked Sep 18 '14 16:09

Dirty Henry


People also ask

Is Sidekiq a gem?

Sidekiq is the gem that can be used for this purpose. Sidekiq uses multiple threads. The default thread in sidekiq is “Default”. * For sidekiq, we need to install redis server.

How do I run Sidekiq in the background?

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.

Is Sidekiq multithreaded?

At the same time, Sidekiq uses multithreading so it is much more memory-efficient than Rescue.

How many Sidekiq threads are there?

By default Sidekiq uses 10 threads which means that either your database on your worker will need to be 10+ threads or you will need to configure your Sidekiq process to use fewer threads.


2 Answers

I came across this same issue. Sidekiq 3.2.4 relies on the Celluloid gem at version 0.16.0, which partially breaks Sidekiq. See here: https://github.com/celluloid/celluloid/issues/457

Update Sidekiq to 3.2.5 which locks Celluloid at version 0.15.2.

like image 189
Chris Yuska Avatar answered Oct 05 '22 22:10

Chris Yuska


It's possible you have another thread in your Sidekiq process which is not stopping, maybe because you are rescuing Exception.

like image 26
Mike Perham Avatar answered Oct 05 '22 20:10

Mike Perham