Class: Rack::Handler::David

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/handler/david.rb

Class Method Summary collapse

Class Method Details

.run(app, options = {}) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rack/handler/david.rb', line 4

def self.run(app, options={})
  g = Celluloid::Supervision::Container.run!

  g.supervise(as: :server, type: ::David::Server, args: [app, options])
  g.supervise(as: :gc, type: ::David::GarbageCollector)

  if options[:Observe] != 'false'
    g.supervise(as: :observe, type: ::David::Observe)
  end

  begin
    Celluloid::Actor[:server].run
  rescue Interrupt
    Celluloid.logger.info 'Terminated'
    Celluloid.logger = nil
    g.terminate
  end
end

.valid_optionsObject


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rack/handler/david.rb', line 23

def self.valid_options
  host, port, maddrs =
    AppConfig::DEFAULT_OPTIONS.values_at(:Host, :Port, :MulticastGroups)

  {
    'Block=BOOLEAN'         => 'Support for blockwise transfer (default: true)',
    'CBOR=BOOLEAN'          => 'Transparent JSON/CBOR conversion (default: false)',
    'DefaultFormat=F'       => 'Content-Type if CoAP accept option on request is undefined',
    'Host=HOST'             => "Hostname to listen on (default: #{host})",
    'Log=LOG'               => 'Change logging (debug|none)',
    'Multicast=BOOLEAN'     => 'Multicast support (default: true)',
    'MulticastGroups=ARRAY' => "Multicast groups (default: #{maddrs.join(', ')})",
    'Observe=BOOLEAN'       => 'Observe support (default: true)',
    'Port=PORT'             => "Port to listen on (default: #{port})"
  }
end