Class: Woodhouse::Server

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Util
Defined in:
lib/woodhouse/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyw = {}) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
# File 'lib/woodhouse/server.rb', line 12

def initialize(keyw = {})
  self.layout        = keyw[:layout]
  self.node          = keyw[:node]
  self.configuration = keyw[:configuration] || Woodhouse.global_configuration
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

#layoutObject

Returns the value of attribute layout.



7
8
9
# File 'lib/woodhouse/server.rb', line 7

def layout
  @layout
end

#nodeObject

Returns the value of attribute node.



7
8
9
# File 'lib/woodhouse/server.rb', line 7

def node
  @node
end

Instance Method Details

#ready_to_start?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/woodhouse/server.rb', line 41

def ready_to_start?
  @node and @layout and @layout.node(@node)
end

#reloadObject



37
38
39
# File 'lib/woodhouse/server.rb', line 37

def reload
  dispatch_layout_changes!
end

#shutdownObject

TODO: do this better



46
47
48
49
50
51
# File 'lib/woodhouse/server.rb', line 46

def shutdown
  @scheduler.spin_down
  @scheduler.terminate
  configuration.triggers.trigger :server_end
  signal :shutdown
end

#startObject



28
29
30
31
32
33
34
35
# File 'lib/woodhouse/server.rb', line 28

def start
  # TODO: don't pass global config
  @scheduler ||= Woodhouse::Scheduler.new_link(configuration)
  return false unless ready_to_start?
  configuration.triggers.trigger :server_start
  dispatch_layout_changes
  true
end