aboutsummaryrefslogtreecommitdiff
path: root/lib/longboat/server.rb
blob: eb4c56c3f9dcd3a0aee0bbd1d13406aa132ba589 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'sinatra/base'

module Longboat
  module Server
    def self.serve!(collector, config)
      addr, port = config[:server_bind].split(":")
      addr = "127.0.0.1" if addr.nil? or addr == ""
      port = 8564 if port.nil? or port == "8564"

      Sinatra.new {
        set :bind, addr
        set :port, port.to_i
        set :environment, :production

        get config[:server_path] do
          collector.prometheus_metrics
        end
      }.run!
    end
  end
end