summaryrefslogtreecommitdiff
path: root/lib/gitlab/sidekiq_versioning.rb
blob: 8164a5a9d7a833f91a2b463ad18119b80ba354a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Gitlab
  module SidekiqVersioning
    def self.install!
      Sidekiq::Manager.prepend SidekiqVersioning::Manager

      # The Sidekiq client API always adds the queue to the Sidekiq queue
      # list, but mail_room and gitlab-shell do not. This is only necessary
      # for monitoring.
      begin
        queues = SidekiqConfig.worker_queues

        if queues.any?
          Sidekiq.redis do |conn|
            conn.pipelined do
              queues.each do |queue|
                conn.sadd('queues', queue)
              end
            end
          end
        end
      rescue ::Redis::BaseError, SocketError, Errno::ENOENT, Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT, Errno::ECONNRESET, Errno::ECONNREFUSED
      end
    end
  end
end