Module: Capistrano::MagicRecipes::SidekiqHelpers

Defined in:
lib/capistrano/magic_recipes/sidekiq_helpers.rb

Instance Method Summary collapse

Instance Method Details

#for_each_process(reverse = false, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/capistrano/magic_recipes/sidekiq_helpers.rb', line 6

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

#processes_deamonesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/capistrano/magic_recipes/sidekiq_helpers.rb', line 16

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

#sidekiq_special_config(idx) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/capistrano/magic_recipes/sidekiq_helpers.rb', line 42

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