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.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#launcher ⇒ Object
Returns the value of attribute launcher.
Instance Method Summary collapse
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #interrupt ⇒ Object
- #parse(args = ARGV) ⇒ Object
- #run ⇒ Object
Methods included from Util
#hostname, #logger, #process_id, #redis, #watchdog
Methods included from ExceptionHandler
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
63 64 65 66 67 |
# File 'lib/sidekiq/cli.rb', line 63 def initialize @code = nil @interrupt_mutex = Mutex.new @interrupted = false end |
Instance Attribute Details
#code ⇒ Object
Used for CLI testing
59 60 61 |
# File 'lib/sidekiq/cli.rb', line 59 def code @code end |
#environment ⇒ Object
Returns the value of attribute environment.
61 62 63 |
# File 'lib/sidekiq/cli.rb', line 61 def environment @environment end |
#launcher ⇒ Object
Returns the value of attribute launcher.
60 61 62 |
# File 'lib/sidekiq/cli.rb', line 60 def launcher @launcher end |
Instance Method Details
#interrupt ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/sidekiq/cli.rb', line 112 def interrupt @interrupt_mutex.synchronize do unless @interrupted @interrupted = true Thread.main.raise Interrupt end end end |
#parse(args = ARGV) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sidekiq/cli.rb', line 69 def parse(args=ARGV) @code = nil (args) initialize_logger validate! daemonize write_pid load_celluloid boot_system end |
#run ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/sidekiq/cli.rb', line 81 def run logger.info "Booting Sidekiq #{Sidekiq::VERSION} with Redis at #{redis {|x| x.client.id}}" logger.info "Running in #{RUBY_DESCRIPTION}" logger.info Sidekiq::LICENSE Sidekiq::Stats::History.cleanup if ![:daemon] logger.info 'Starting processing, hit Ctrl-C to stop' end require 'sidekiq/launcher' @launcher = Sidekiq::Launcher.new() launcher.procline([:tag] ? "#{[:tag]} " : '') begin if [:profile] require 'ruby-prof' RubyProf.start end launcher.run sleep rescue Interrupt logger.info 'Shutting down' launcher.stop # Explicitly exit so busy Processor threads can't block # process shutdown. exit(0) end end |