From c6f9cc07872d4a17ad3908493fb9cfd69c4382d3 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 23 Apr 2014 11:01:17 +1000 Subject: [PATCH] UPGRADE: sidekiq to sidekiq 3.0 --- Gemfile.lock | 4 ++-- config/initializers/sidekiq.rb | 6 ++---- lib/discourse.rb | 10 ++++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 07701afeaf2..4a31c16b0ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -318,9 +318,9 @@ GEM shoulda-context (1.1.6) shoulda-matchers (2.5.0) activesupport (>= 3.0.0) - sidekiq (2.17.6) + sidekiq (3.0.0) celluloid (>= 0.15.2) - connection_pool (>= 1.0.0) + connection_pool (>= 2.0.0) json redis (>= 3.0.6) redis-namespace (>= 1.3.1) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 1c8d76756d8..0cfdbf90f90 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,13 +1,11 @@ require "sidekiq/pausable" -sidekiq_redis = { url: $redis.url, namespace: 'sidekiq' } - Sidekiq.configure_client do |config| - config.redis = sidekiq_redis + config.redis = Discourse.sidekiq_redis_config end Sidekiq.configure_server do |config| - config.redis = sidekiq_redis + config.redis = Discourse.sidekiq_redis_config # add our pausable middleware config.server_middleware do |chain| chain.add Sidekiq::Pausable diff --git a/lib/discourse.rb b/lib/discourse.rb index 2d652cc0538..835636aba0f 100644 --- a/lib/discourse.rb +++ b/lib/discourse.rb @@ -245,8 +245,14 @@ module Discourse SiteSetting.after_fork $redis.client.reconnect Rails.cache.reconnect - # /!\ HACK /!\ force sidekiq to create a new connection to redis - Sidekiq.instance_variable_set(:@redis, nil) + # shuts down all connections in the pool + Sidekiq.redis_pool.shutdown{|c| nil} + # re-establish + Sidekiq.redis = sidekiq_redis_config + end + + def self.sidekiq_redis_config + { url: $redis.url, namespace: 'sidekiq' } end end