Class: Rackdapter::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/rackdapter/spawner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Application

Returns a new instance of Application.



6
7
8
9
10
11
12
13
14
# File 'lib/rackdapter/spawner.rb', line 6

def initialize(options={})
  options.each do |k,v|
    send("#{k.to_s}=".to_sym, v)
  end
  @app_instances = {}
  ports.each do |port|
    @app_instances[port] = ApplicationInstance.new(self, port)
  end
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def backend
  @backend
end

#balancerObject

Returns the value of attribute balancer.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def balancer
  @balancer
end

#base_portObject

Returns the value of attribute base_port.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def base_port
  @base_port
end

#environmentObject

Returns the value of attribute environment.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def environment
  @environment
end

#instancesObject

Returns the value of attribute instances.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def instances
  @instances
end

#logObject

Returns the value of attribute log.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def log
  @log
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def name
  @name
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def path
  @path
end

#portObject

Returns the value of attribute port.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def port
  @port
end

#rubyObject

Returns the value of attribute ruby.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def ruby
  @ruby
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/rackdapter/spawner.rb', line 4

def type
  @type
end

Instance Method Details

#all_instances(&block) ⇒ Object



38
39
40
41
42
# File 'lib/rackdapter/spawner.rb', line 38

def all_instances(&block)
  @app_instances.each do |port,instance|
    instance.send(:instance_eval, &block)
  end
end

#app_instancesObject



16
17
18
# File 'lib/rackdapter/spawner.rb', line 16

def app_instances
  @app_instances
end

#next_portObject



20
21
22
23
# File 'lib/rackdapter/spawner.rb', line 20

def next_port
  @balancer ||= ProxyBalancer.new(ports)
  @balancer.next_port
end

#portsObject



25
26
27
28
29
30
31
32
# File 'lib/rackdapter/spawner.rb', line 25

def ports
  return @ports if @ports
  @ports = []
  instances.times do |i|
    @ports << base_port + i
  end
  @ports
end