Class: Sidekiq::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

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

Constructor Details

#initializeCLI

Returns a new instance of CLI.


25
26
27
# File 'lib/sidekiq/cli.rb', line 25

def initialize
  @code = nil
end

Instance Attribute Details

#codeObject

Used for CLI testing


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

def code
  @code
end

Instance Method Details

#parse(args = ARGV) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sidekiq/cli.rb', line 29

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

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

  set_logger_level_to_debug if options[:verbose]

  write_pid
  validate!
  boot_system
end

#runObject


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

def run
  manager = Sidekiq::Manager.new(options)
  begin
    logger.info 'Starting processing, hit Ctrl-C to stop'
    manager.start!
    # HACK need to determine how to pause main thread while
    # waiting for signals.
    sleep
  rescue Interrupt
    # TODO Need clean shutdown support from Celluloid
    logger.info 'Shutting down'
    manager.stop!
    manager.wait(:shutdown)
  end
end