class Backdat::Server

The backdat server and management daemon.

Public Class Methods

new() click to toggle source

Creates a new backdat server.

# File lib/backdat/server.rb, line 9
def initialize
end

Public Instance Methods

rack_options() click to toggle source

Gets the rack options from the configuration.

@return [ Hash ] The rack options from Backdat::Config.

# 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
run() click to toggle source

Runs the server.

# 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