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.
- #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.
29 30 31 |
# File 'lib/sidekiq/cli.rb', line 29 def initialize @code = nil end |
Instance Attribute Details
#code ⇒ Object
Used for CLI testing
25 26 27 |
# File 'lib/sidekiq/cli.rb', line 25 def code @code end |
#environment ⇒ Object
Returns the value of attribute environment.
27 28 29 |
# File 'lib/sidekiq/cli.rb', line 27 def environment @environment end |
#launcher ⇒ Object
Returns the value of attribute launcher.
26 27 28 |
# File 'lib/sidekiq/cli.rb', line 26 def launcher @launcher end |
Instance Method Details
#parse(args = ARGV) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekiq/cli.rb', line 33 def parse(args=ARGV) @code = nil (args) initialize_logger validate! daemonize write_pid load_celluloid boot_system end |
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/sidekiq/cli.rb', line 45 def run self_read, self_write = IO.pipe %w(INT TERM USR1 USR2 TTIN).each do |sig| begin trap sig do self_write.puts(sig) end rescue ArgumentError puts "Signal #{sig} not supported" end end redis {} # noop to connect redis and print info logger.info "Running in #{RUBY_DESCRIPTION}" logger.info Sidekiq::LICENSE 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 while readable_io = IO.select([self_read]) signal = readable_io.first[0].gets.strip handle_signal(signal) end rescue Interrupt logger.info 'Shutting down' launcher.stop # Explicitly exit so busy Processor threads can't block # process shutdown. exit(0) end end |