Class: Backdat::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/backdat/server.rb

Overview

The backdat server and management daemon.

Instance Method Summary collapse

Constructor Details

#initializeServer

Creates a new backdat server.



9
10
# File 'lib/backdat/server.rb', line 9

def initialize
end

Instance Method Details

#rack_optionsHash

Gets the rack options from the configuration.

Returns:

  • (Hash)

    The rack options from Backdat::Config.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/backdat/server.rb', line 30

def rack_options
  opts = Hash.new
  Backdat::Config.configuration.each do |k,v|
    if /^rack/ =~ k.to_s
      param = k.to_s.gsub('rack_', '')

      case param
      when "environment"
        opts[param.to_sym] = v
      else
        opts[param.capitalize.to_sym] = v
      end
    end
  end
  opts
end

#runObject

Runs the server.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/backdat/server.rb', line 13

def run
  if Backdat::Config[:server]
    EM.run do
      @app = Rack::Builder.new do
        use Rack::Lint
        use Rack::ShowExceptions
        run Rack::Cascade.new([Backdat::Http])
      end.to_app

      Rack::Handler.get(:puma).run(@app, rack_options)
    end
  end
end