Class: PushyDaemon::Proxy

Inherits:
BmcDaemonLib::MqEndpoint
  • Object
show all
Defined in:
lib/pushyd/proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProxy

Returns a new instance of Proxy.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/pushyd/proxy.rb', line 17

def initialize
  # Init
  @shouter = nil
  @consumers = []

  # Init ASCII table
  @table = Terminal::Table.new
  @table.title = "Rules summary"
  @table.headings = ["rule", "topic", "> queue", "> relay", "routing key", "bind status"]
  @table.align_column(5, :right)

  # Prepare logger
  @logger = BmcDaemonLib::LoggerPool.instance.get

  # Start connexion to RabbitMQ
  connect_to BmcDaemonLib::Conf[:broker]

  # Create a new shouter
  create_shouter

  # Check config and subscribe rules
  create_consumers

  # Send config table to logs
  log_info "Proxy initialized", @table.to_s
  puts @table.to_s

  # Make the shouter loop!
  @shouter.start_loop

  rescue BmcDaemonLib::MqConsumerException => e
    log_error "Proxy exception: #{e.message}"
    abort "EXITING #{e.class}: #{e.message}"

  rescue ShouterInterrupted, ProxyConnectionError, Errno::EACCES => e
    log_error "Proxy error: #{e.message}"
    abort "EXITING #{e.class}: #{e.message}"

  rescue StandardError => e
    log_error "Proxy unexpected: #{e.message}", e.backtrace
    abort "EXITING #{e.class}: #{e.message} \n #{e.backtrace.to_yaml}"
    # raise MqConsumerException, e.message

end

Instance Attribute Details

#tableObject

Class options



15
16
17
# File 'lib/pushyd/proxy.rb', line 15

def table
  @table
end