Sha256: b68ebda20169cbc19802adaada9e56bdf0874edba65899f0ddcb1b21eb668cc1

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 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,
            network_timeout: 10
          }

          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,
            network_timeout: 10
          }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.106 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.105 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.104 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.103 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.102 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.101 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.100 lib/neeto_commons_backend/initializers/sidekiq.rb