Class: Sidekiq::Pool::CLI

Inherits:
CLI
  • Object
show all
Defined in:
lib/sidekiq/pool/cli.rb

Constant Summary collapse

START_CTX =
{
  :argv => ARGV.map(&:dup),
  0 => $0.dup,
}

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



13
14
15
16
17
18
# File 'lib/sidekiq/pool/cli.rb', line 13

def initialize
  @pool = []
  @done = false
  @system_booted = false
  super
end

Instance Method Details

#parse_config_file(filename) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/sidekiq/pool/cli.rb', line 37

def parse_config_file(filename)
  config = YAML.load(ERB.new(File.read(filename)).result)
  unless config.key?(:workers)
    raise ArgumentError, 'Invalid configuration file - "workers" key must be present'
  end
  unless config[:workers].is_a?(Array)
    raise ArgumentError, 'Invalid configuration file - "workers" key must be a list'
  end
  unless config[:workers].size > 0
    raise ArgumentError, 'Invalid configuration file - Atleast one worker must be present'
  end
  config
end

#runObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/sidekiq/pool/cli.rb', line 26

def run
  @master_pid = $$
  write_pid

  trap_signals
  update_process_name
  start_new_pool

  wait_for_signals
end

#run_childObject



20
# File 'lib/sidekiq/pool/cli.rb', line 20

alias_method :run_child, :run

#write_pidObject



22
23
24
# File 'lib/sidekiq/pool/cli.rb', line 22

def write_pid
  super if @master_pid == ::Process.pid
end