Class: GitLab::Exporter::CLI::Server

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

Overview

Run a web server that exposes the metrics specified in a config file

Constant Summary collapse

COMMAND_NAME =
"web".freeze

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Server

Returns a new instance of Server.



166
167
168
169
# File 'lib/gitlab_exporter/cli.rb', line 166

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

Instance Method Details

#helpObject



180
181
182
# File 'lib/gitlab_exporter/cli.rb', line 180

def help
  @options.help
end

#options(args) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/gitlab_exporter/cli.rb', line 171

def options(args)
  args.options do |opts|
    opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]"
    opts.on("-c config.yml", "Monitoring config") do |val|
      @config_file = val
    end
  end
end

#runObject



184
185
186
187
188
189
190
191
# File 'lib/gitlab_exporter/cli.rb', line 184

def run
  validate!

  config = Utils.deep_symbolize_hash_keys(YAML.load_file(@config_file))

  WebExporter.setup(config)
  WebExporter.run!
end