Sha256: 610e847ec6a74885f68ffae8e762902ec5715a7281ca4e202ff723069b0767c7

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

module Capistrano
  module MagicRecipes
    module SidekiqHelpers
      
      
      def for_each_process(reverse = false, &block)
        pids = processes_deamones
        pids.reverse! if reverse
        pids.each_with_index do |service_file, idx|
          within fetch(:sidekiq_six_deamon_path) do
            yield(service_file, idx)
          end
        end
      end
  
      def processes_deamones
        deamons = []
        if fetch(:sidekiq_six_special_queues)
          fetch(:sidekiq_six_queued_processes, []).each do |qp|
            counter = (qp[:processes] && qp[:processes].to_i > 0 ? qp[:processes].to_i : 1)
            if counter > 1
              counter.times do |idx|
                deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }-#{ idx }"
              end
            else
              deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ qp[:queue] }"
            end
          end
        else
          counter = fetch(:sidekiq_six_processes).to_i 
          if counter > 1
            counter.times do |idx|
              deamons.push "#{ fetch(:sidekiq_six_deamon_file) }-#{ idx }"
            end
          else
            deamons.push "#{ fetch(:sidekiq_six_deamon_file) }"
          end
        end
        deamons
      end
  
      def sidekiq_special_config(idx)
        if fetch(:sidekiq_six_special_queues)
          settingz = []
          fetch(:sidekiq_six_queued_processes).each do |that|
            (that[:processes] && that[:processes].to_i > 0 ? that[:processes].to_i : 1 ).to_i.times do
              sttng_hash = {}
              sttng_hash[:queue] = that[:queue] ? that[:queue] : "default"
              sttng_hash[:concurrency] = that[:worker] && that[:worker].to_i > 0 ? that[:worker].to_i : 7
              settingz.push( sttng_hash )
            end
          end
          settingz[ idx.to_i ]
        else
          {}
        end
      end
      
      
    end
  end
end




Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_recipes_two-0.0.95 lib/capistrano/magic_recipes/sidekiq_helpers.rb