summaryrefslogtreecommitdiff
path: root/lib/nickserver/server.rb
blob: 8f4a49f4d29df9fd4074841db531c0a8833a7d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'kernel_ext'
require 'json'
require 'nickserver/reel_server'


#
# This is the main HTTP server that clients connect to in order to fetch keys
#
#
module Nickserver
  class Server

    #
    # Starts the Nickserver.
    #
    # Available options:
    #
    #   * :port (default Nickserver::Config.port)
    #   * :host (default 127.0.0.1)
    #
    def self.start(opts={})
      Nickserver::Config.load
      options = {
        host: '127.0.0.1',
        port: Nickserver::Config.port.to_i
      }.merge(opts)

      unless defined?(TESTING)
        puts "Starting nickserver #{options[:host]}:#{options[:port]}"
      end

      Nickserver::ReelServer.start(options)
    end


  end
end