Class: Sidekiq::CLI

Inherits:
Object
  • Object
show all
Includes:
Util, Singleton
Defined in:
lib/sidekiq/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#constantize, logger, #logger, logger=, #process_id, #redis, #watchdog

Constructor Details

#initializeCLI

Returns a new instance of CLI.



33
34
35
36
# File 'lib/sidekiq/cli.rb', line 33

def initialize
  @code = nil
  @manager = nil
end

Instance Attribute Details

#codeObject

Used for CLI testing



31
32
33
# File 'lib/sidekiq/cli.rb', line 31

def code
  @code
end

#managerObject

Used for CLI testing



31
32
33
# File 'lib/sidekiq/cli.rb', line 31

def manager
  @manager
end

Instance Method Details

#parse(args = ARGV) ⇒ Object



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

def parse(args=ARGV)
  @code = nil
  Sidekiq::Util.logger

  cli = parse_options(args)
  config = parse_config(cli)
  options.merge!(config.merge(cli))

  Sidekiq::Util.logger.level = Logger::DEBUG if options[:verbose]

  validate!
  write_pid
  boot_system
end

#runObject



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sidekiq/cli.rb', line 53

def run
  @manager = Sidekiq::Manager.new(options)
  begin
    logger.info 'Starting processing, hit Ctrl-C to stop'
    manager.start!
    sleep
  rescue Interrupt
    logger.info 'Shutting down'
    manager.stop!(:shutdown => true, :timeout => options[:timeout])
    manager.wait(:shutdown)
  end
end