Sha256: 8fc586c1bbaf0568bc053e7fef8cff0a3a4ed8917e392dc28170e237a51cc0e6

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 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, aliases: true)
            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

3 entries across 3 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.108 lib/neeto_commons_backend/initializers/sidekiq.rb
neeto-commons-backend-1.0.107 lib/neeto_commons_backend/initializers/sidekiq.rb