Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gracefully shutting down sidekiq processes

Tags:

ruby

sidekiq

Does anyone know how to find sidekiq's pidfile to gracefully shut it down? Running ps ax | grep sidekiq and then running sidekiqctl stop <pid from grep> consistently gives a no such pidfile error? Cntl-C and Cntl-D also seem to have no effect.

Closing the process window and reopening a new window doesn't kill the process as it appears to be running as a daemon.

The only consistent fix I've found is rebooting.

like image 419
user1627827 Avatar asked Aug 27 '12 13:08

user1627827


People also ask

How do you kill a Sidekiq process?

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.

How do you stop a Sidekiq worker?

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.

What is a Sidekiq process?

Sidekiq is an open-source framework that provides efficient background processing for Ruby applications. It uses Redis as an in-memory data structure to store all of its job and operational data. It's important to be aware that Sidekiq by default doesn't do scheduling, it only executes jobs.


2 Answers

Use this to kill sidekiq forcefully.

ps -ef | grep sidekiq | grep -v grep | awk '{print $2}' | xargs kill -9 
like image 61
Paritosh Piplewar Avatar answered Nov 10 '22 02:11

Paritosh Piplewar


Sidekiq provides the ability to specify a pidfile at start time or, as shown below, to create the pidfile after the process has been started. In either case you can then use the pidfile at stop time.

  1. Use ps -ef | grep sidekiq to find the pid
  2. Create a file (e.g., sidekiq.pid) with the only contents being the pid you just found
  3. sidekiqctl stop <pidfile_name>
  4. Use -P <pidfile_name> or --pidfile <pidfile_name> when starting sidekiq in the future
like image 33
eebbesen Avatar answered Nov 10 '22 03:11

eebbesen