summaryrefslogtreecommitdiff
path: root/lib/oxidized/api/web.rb
blob: 9a5a5076dfe01e7e42099233a8bbc6dec25d1b47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Oxidized
  module API
    class Web
      attr_reader :thread
      def initialize nodes, listen
        require 'oxidized/api/web/webapp'
        addr, port = listen.to_s.split ':'
        port, addr = addr, nil if not port
        WebApp.set :server, %w(puma)
        WebApp.set :bind, addr if addr
        WebApp.set :port, port
        WebApp.set :nodes, nodes
      end
      def run
        @thread = Thread.new { WebApp.run! }
      end
    end
  end
end