Sha256: 0432c086d12d992f064b53dee03d58272f9345807e36489452c95002e4bfd220

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

if defined?(PhusionPassenger)
  PhusionPassenger.on_event(:starting_worker_process) do |forked|
    # We're in smart spawning mode.
    if forked
      # Re-establish redis connection
      require 'redis'
      config = YAML.load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access

      # The important two lines
      $redis.client.disconnect if $redis
      $redis = begin
                 Redis.new(host: config[:host], port: config[:port], thread_safe: true)
               rescue
                 nil
               end
      Resque.redis = $redis
      Resque.redis.namespace = "#{CurationConcerns.config.redis_namespace}:#{Rails.env}"
      Resque.redis.client.reconnect if Resque.redis
    end
  end
else
  config = YAML.load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
  $redis = begin
             Redis.new(host: config[:host], port: config[:port], thread_safe: true)
           rescue
             nil
           end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
curation_concerns-models-0.9.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.8.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.7.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.6.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.5.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.4.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.3.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb
curation_concerns-models-0.2.0 lib/generators/curation_concerns/models/templates/config/redis_config.rb