diff --git a/config/initializers/redis_config.rb b/config/initializers/redis_config.rb index 772ddd2be..9a923b774 100644 --- a/config/initializers/redis_config.rb +++ b/config/initializers/redis_config.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -config = YAML.safe_load(ERB.new(IO.read(Rails.root + 'config' + 'redis.yml')).result)[Rails.env].with_indifferent_access -sentinels = config[:sentinel] && config[:sentinel][:host].present? ? { sentinels: [config[:sentinel]] } : {} -redis_config = config.except(:sentinel).merge(thread_safe: true).merge(sentinels) require 'redis' -Redis.current = begin - Redis.new(redis_config) - rescue - nil - end +require 'connection_pool' +config = YAML.safe_load(ERB.new(IO.read(Rails.root.join('config', 'redis.yml'))).result)[Rails.env].with_indifferent_access + +size = ENV.fetch("HYRAX_REDIS_POOL_SIZE", 5) +timeout = ENV.fetch("HYRAX_REDIS_TIMEOUT", 5) + +Hyrax.config.redis_connection = + ConnectionPool::Wrapper.new(size: size, timeout: timeout) { Redis.new(config) } diff --git a/spec/features/admin_dashboard_spec.rb b/spec/features/admin_dashboard_spec.rb index 3eef1f164..8a10076cc 100644 --- a/spec/features/admin_dashboard_spec.rb +++ b/spec/features/admin_dashboard_spec.rb @@ -49,10 +49,10 @@ it 'shows the status page' do visit status_path - expect(page).to have_content("Fedora\nOK") - expect(page).to have_content("Solr\nOK") - expect(page).to have_content("Redis\nOK") - expect(page).to have_content("Database\nOK") + expect(page).to have_selector(".list-group-item-success", text: "Fedora OK") + expect(page).to have_selector(".list-group-item-success", text: "Solr OK") + expect(page).to have_selector(".list-group-item-success", text: "Redis OK") + expect(page).to have_selector(".list-group-item-success", text: "Database OK") end it 'displays the add-users-to-groups page without the hidden form field', js: true do