Class: Sidekiq::CLI

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

Constant Summary collapse

FOREVER =
2_000_000_000

Instance Method Summary collapse

Methods included from Util

#constantize, #err, #log, #verbose, #watchdog

Constructor Details

#initializeCLI

Returns a new instance of CLI.



12
13
14
15
16
# File 'lib/sidekiq/cli.rb', line 12

def initialize
  parse_options
  validate!
  boot_rails
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sidekiq/cli.rb', line 20

def run
  ::Sidekiq::Client.redis = ConnectionPool.new { Redis.connect(:url => @options[:server]) }
  manager = Sidekiq::Manager.new(@options[:server], @options)
  begin
    log 'Starting processing, hit Ctrl-C to stop'
    manager.start!
    # HACK need to determine how to pause main thread while
    # waiting for signals.
    sleep FOREVER
  rescue Interrupt
    # TODO Need clean shutdown support from Celluloid
    log 'Shutting down, pausing 5 seconds to let workers finish...'
    manager.stop!
    manager.wait(:shutdown)
  end
end