Class: Souffle::Server

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

Overview

The souffle server and management daemon.

Instance Method Summary collapse

Constructor Details

#initializeServer

Creates a new souffle server.



10
11
# File 'lib/souffle/server.rb', line 10

def initialize
end

Instance Method Details

#rack_optionsHash

Gets the rack options from the configuration.

Returns:

  • (Hash)

    The rack options from Souffle::Config.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/souffle/server.rb', line 25

def rack_options
  opts = Hash.new
  Souffle::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.



14
15
16
17
18
19
20
# File 'lib/souffle/server.rb', line 14

def run
  if Souffle::Config[:server]
    run_server
  else
    run_instance
  end
end

#run_instanceObject

Starts a single instance of the provisioner.



56
57
58
59
60
61
# File 'lib/souffle/server.rb', line 56

def run_instance
  Souffle::Log.info "Single instance runs are not currently implemented..."
  # system = Souffle::System.from_hash(data)
  # provider = Souffle::Provider.plugin(system.try_opt(:provider)).new
  # system_tag = provider.create_system(system)
end

#run_serverObject

Starts a long-running webserver that continuously handles requests.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/souffle/server.rb', line 43

def run_server
  EM.synchrony do
    @app = Rack::Builder.new do
      use Rack::Lint
      use Rack::ShowExceptions
      run Rack::Cascade.new([Souffle::Http])
    end.to_app

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