Class: Sidekiq::CLI
- Inherits:
-
Object
- Object
- Sidekiq::CLI
- Includes:
- Util, Singleton
- Defined in:
- lib/sidekiq/cli.rb
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#code ⇒ Object
Used for CLI testing.
-
#manager ⇒ Object
Returns the value of attribute manager.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #interrupt ⇒ Object
- #parse(args = ARGV) ⇒ Object
- #run ⇒ Object
Methods included from Util
#constantize, #logger, #process_id, #redis, #watchdog
Methods included from ExceptionHandler
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
46 47 48 49 50 |
# File 'lib/sidekiq/cli.rb', line 46 def initialize @code = nil @interrupt_mutex = Mutex.new @interrupted = false end |
Instance Attribute Details
#code ⇒ Object
Used for CLI testing
43 44 45 |
# File 'lib/sidekiq/cli.rb', line 43 def code @code end |
#manager ⇒ Object
Returns the value of attribute manager.
44 45 46 |
# File 'lib/sidekiq/cli.rb', line 44 def manager @manager end |
Instance Method Details
#interrupt ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/sidekiq/cli.rb', line 87 def interrupt @interrupt_mutex.synchronize do unless @interrupted @interrupted = true Thread.main.raise Interrupt end end end |
#parse(args = ARGV) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sidekiq/cli.rb', line 52 def parse(args=ARGV) @code = nil Sidekiq.logger cli = (args) config = parse_config(cli) .merge!(config.merge(cli)) Sidekiq.logger.level = Logger::DEBUG if [:verbose] Celluloid.logger = nil unless [:verbose] validate! write_pid boot_system end |
#run ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sidekiq/cli.rb', line 68 def run @manager = Sidekiq::Manager.new() poller = Sidekiq::Scheduled::Poller.new begin logger.info 'Starting processing, hit Ctrl-C to stop' @manager.start! poller.poll!(true) sleep rescue Interrupt logger.info 'Shutting down' poller.terminate! if poller.alive? @manager.stop!(:shutdown => true, :timeout => [:timeout]) @manager.wait(:shutdown) # Explicitly exit so busy Processor threads can't block # process shutdown. exit(0) end end |