Class: GitLab::Monitor::CLI::SidekiqRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_monitor/cli.rb

Overview

Sidekiq runner.

It will take a Redis connection URL and print results to STDOUT

Constant Summary collapse

COMMAND_NAME =
"sidekiq".freeze

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ SidekiqRunner

Returns a new instance of SidekiqRunner.



252
253
254
255
256
257
258
# File 'lib/gitlab_monitor/cli.rb', line 252

def initialize(args)
  @options = options(args)
  @options.parse!

  @target = args.shift || STDOUT
  @target = File.open(@target, "a") if @target.is_a?(String)
end

Instance Method Details

#helpObject



269
270
271
# File 'lib/gitlab_monitor/cli.rb', line 269

def help
  @options.help
end

#options(args) ⇒ Object



260
261
262
263
264
265
266
267
# File 'lib/gitlab_monitor/cli.rb', line 260

def options(args)
  args.options do |opts|
    opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]"
    opts.on("--redis-url=\"redis://localhost:6379\"", "Redis URL") do |val|
      @redis_url = val
    end
  end
end

#runObject



273
274
275
276
277
278
279
280
281
282
283
# File 'lib/gitlab_monitor/cli.rb', line 273

def run
  validate!

  ::GitLab::Monitor::SidekiqProber.new(redis_url: @redis_url)
                                  .probe_stats
                                  .probe_queues
                                  .probe_jobs
                                  .probe_workers
                                  .probe_retries
                                  .write_to(@target)
end