Class: GitLab::Monitor::CLI::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_monitor/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.


167
168
169
170
# File 'lib/gitlab_monitor/cli.rb', line 167

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

Instance Method Details

#helpObject


181
182
183
# File 'lib/gitlab_monitor/cli.rb', line 181

def help
  @options.help
end

#options(args) ⇒ Object


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

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


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

def run
  validate!

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

  WebExporter.setup(config)
  WebExporter.run!
end