Sha256: b044d9e41d8e97f86c84d190fdffce17249d4498958f740ec13219526c98112b

Contents?: true

Size: 1.31 KB

Versions: 11

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require "sidekiq"
require "sidekiq-cron"

module NeetoCommonsBackend
  module Initializers
    class << self
      def sidekiq
        if Rails.env.test? || Rails.env.heroku?
          require "sidekiq/testing"
          Sidekiq::Testing.inline!
        end

        Sidekiq.logger.level = Logger::WARN if Rails.env.test?

        Sidekiq.configure_server do |config|
          # Reference:
          # 1. https://github.com/mperham/sidekiq/wiki/Using-Redis#complete-control
          # 2. https://elements.heroku.com/addons/heroku-redis Max connection 20
          config.redis = {
            url: Rails.application.secrets.redis_url,
            size: 18,
            reconnect_attempts: 2
          }

          unless Rails.env.test? || Rails.env.production? || Rails.env.staging?
            schedule_file = "config/scheduled_jobs.yml"
            if File.exist?(schedule_file)
              Sidekiq::Cron::Job.load_from_hash! YAML.load_file(schedule_file, aliases: true)[Rails.env] ||
                YAML.load_file(schedule_file)
            end
          end
        end

        Sidekiq.configure_client do |config|
          config.redis = {
            url: Rails.application.secrets.redis_url,
            size: 2,
            reconnect_attempts: 2
          }
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.99 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.98 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.97 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.96 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.95 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.94 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.93 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.92 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.91 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.90 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.89 lib/neeto_commons_backend/initializers/sidekiq.rb