Class: GitLab::Exporter::CLI::SidekiqRunner
- Inherits:
-
Object
- Object
- GitLab::Exporter::CLI::SidekiqRunner
- Defined in:
- lib/gitlab_exporter/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
- #help ⇒ Object
-
#initialize(args) ⇒ SidekiqRunner
constructor
A new instance of SidekiqRunner.
-
#options(args) ⇒ Object
rubocop:disable Metrics/MethodLength.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ SidekiqRunner
Returns a new instance of SidekiqRunner.
292 293 294 295 296 297 298 |
# File 'lib/gitlab_exporter/cli.rb', line 292 def initialize(args) @options = (args) @options.parse! @target = args.shift || STDOUT @target = File.open(@target, "a") if @target.is_a?(String) end |
Instance Method Details
#help ⇒ Object
321 322 323 |
# File 'lib/gitlab_exporter/cli.rb', line 321 def help @options.help end |
#options(args) ⇒ Object
rubocop:disable Metrics/MethodLength
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/gitlab_exporter/cli.rb', line 300 def (args) # rubocop:disable Metrics/MethodLength args. do |opts| opts. = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]" opts.on("--redis-url=\"redis://localhost:6379\"", "Redis URL") do |val| @redis_url = val end opts.on("--redis-sentinel-username=\"my-sentinel-username\"", "Redis Sentinel username") do |val| @redis_sentinel_username = val end opts.on("--redis-sentinel-password=\"my-sentinel-password\"", "Redis Sentinel password") do |val| @redis_sentinel_password = val end opts.on("--redis-sentinels=HOST1:PORT1,HOST2:PORT2", Array, "List of Redis Sentinels") do |val| @redis_sentinels = val.map { |item| host, port = item.split(":") { host: host, port: port.to_i } } end end end |
#run ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/gitlab_exporter/cli.rb', line 325 def run validate! prober = ::GitLab::Exporter::SidekiqProber.new(redis_url: @redis_url, redis_sentinels: @redis_sentinels, redis_sentinel_username: @redis_sentinel_username, redis_sentinel_password: @redis_sentinel_password, logger: Logger.new(STDERR)) prober .probe_stats .probe_queues .probe_jobs_limit .probe_workers .probe_retries .write_to(@target) end |