summaryrefslogtreecommitdiff
path: root/lib/nickserver/server.rb
blob: 11e7012118c7d08e88df580ca3d58328cf5fd933 (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
38
require 'nickserver/config'
require 'nickserver/reel_server'

require 'kernel_ext'
require 'json'

#
# 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