Module: Deadpool::AdminServer

Defined in:
lib/deadpool/admin_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#deadpool_serverObject

Returns the value of attribute deadpool_server.



8
9
10
# File 'lib/deadpool/admin_server.rb', line 8

def deadpool_server
  @deadpool_server
end

Instance Method Details

#receive_data(data) ⇒ Object

data should be a JSON encoded hash. It must have a command key.

'command' => 'command', 
'pool'    => 'pool_name', 
'server'  => 'server_label'



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/deadpool/admin_server.rb', line 16

def receive_data(data)
  if data.to_s =~ /command/        
    deadpool_server.logger.debug "Received instruction: #{data}"
    options = JSON.parse(data.to_s)

    case options['command']
    when 'full_report'
      send_data full_report
    when 'nagios_report'
      send_data nagios_report
    when 'promote_server'
      send_data promote_server options
    when 'stop'
      send_data stop
    else
      send_data "Server did not understand the command."
    end
  end

  close_connection_after_writing
end