class Sidekiq::CLI
def run
global process state irreversibly. PRs which improve the
Code within this method is not tested because it alters
def run boot_system if environment == "development" && $stdout.tty? && Sidekiq.log_formatter.is_a?(Sidekiq::Logger::Formatters::Pretty) print_banner end logger.info "Booted Rails #{::Rails.version} application in #{environment} environment" if rails_app? self_read, self_write = IO.pipe sigs = %w[INT TERM TTIN TSTP] # USR1 and USR2 don't work on the JVM sigs << "USR2" unless jruby? sigs.each do |sig| trap sig do self_write.puts(sig) end rescue ArgumentError puts "Signal #{sig} not supported" end logger.info "Running in #{RUBY_DESCRIPTION}" logger.info Sidekiq::LICENSE logger.info "Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org" unless defined?(::Sidekiq::Pro) # touch the connection pool so it is created before we # fire startup and start multithreading. ver = Sidekiq.redis_info["redis_version"] raise "You are connecting to Redis v#{ver}, Sidekiq requires Redis v4.0.0 or greater" if ver < "4" # Since the user can pass us a connection pool explicitly in the initializer, we # need to verify the size is large enough or else Sidekiq's performance is dramatically slowed. cursize = Sidekiq.redis_pool.size needed = Sidekiq.options[:concurrency] + 2 raise "Your pool of #{cursize} Redis connections is too small, please increase the size to at least #{needed}" if cursize < needed # cache process identity Sidekiq.options[:identity] = identity # Touch middleware so it isn't lazy loaded by multiple threads, #3043 Sidekiq.server_middleware # Before this point, the process is initializing with just the main thread. # Starting here the process will now have multiple threads running. fire_event(:startup, reverse: false, reraise: true) logger.debug { "Client Middleware: #{Sidekiq.client_middleware.map(&:klass).join(", ")}" } logger.debug { "Server Middleware: #{Sidekiq.server_middleware.map(&:klass).join(", ")}" } launch(self_read) end