summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/initializers/sidekiq_cluster.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/config/initializers/sidekiq_cluster.rb b/config/initializers/sidekiq_cluster.rb
index 4622984fe0c..4ff8dd9b936 100644
--- a/config/initializers/sidekiq_cluster.rb
+++ b/config/initializers/sidekiq_cluster.rb
@@ -13,6 +13,16 @@ if ENV['ENABLE_SIDEKIQ_CLUSTER']
# this case the parent PID changes and we need to terminate ourselves.
if Process.ppid != parent
Process.kill(:TERM, Process.pid)
+
+ # Wait for just a few extra seconds for a final attempt to
+ # gracefully terminate. Considering the parent (cluster) process
+ # have changed (SIGKILL'd), it shouldn't take long to shutdown.
+ sleep(5)
+
+ # Signaling the Sidekiq Pgroup as KILL is not forwarded to
+ # a possible child process. In Sidekiq Cluster, all child Sidekiq
+ # processes are PGROUP leaders (each process has its own pgroup).
+ Process.kill(:KILL, 0)
break
end
end