Class: Cloud::Deploy::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud/deploy/monitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, name) ⇒ Monitor

Returns a new instance of Monitor.



29
30
31
32
33
# File 'lib/cloud/deploy/monitor.rb', line 29

def initialize(config, name)
  @config = config
  @name = name
  @exchange = @config['default']['exchange']
end

Instance Attribute Details

#artifactObject (readonly)

Returns the value of attribute artifact.



26
27
28
# File 'lib/cloud/deploy/monitor.rb', line 26

def artifact
  @artifact
end

#configObject

Returns the value of attribute config.



27
28
29
# File 'lib/cloud/deploy/monitor.rb', line 27

def config
  @config
end

#md5sumObject (readonly)

Returns the value of attribute md5sum.



26
27
28
# File 'lib/cloud/deploy/monitor.rb', line 26

def md5sum
  @md5sum
end

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/cloud/deploy/monitor.rb', line 27

def name
  @name
end

Instance Method Details

#deploy!Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cloud/deploy/monitor.rb', line 35

def deploy!
        defaults = @config['default']

        # Connect to RabbitMQ...
        host = defaults['host']
        port = defaults['port']
        user = defaults['user']
        pass = defaults['password']
        vhost = defaults['virtual_host']
        exchange = defaults['exchange']
        $log.info(@name) { "Connecting to MQ h: #{host}, p: #{port}, u: #{user}, pw: #{pass}, v: #{vhost}, x: #{exchange}" }

        AMQP.start(:host => host, :port => port, :user => user, :pass => pass, :vhost => vhost) do
   MQ.queue(@name).bind(@exchange).subscribe(:ack => true) do |headers, body|
@md5sum = headers.properties[:correlation_id]
@artifact = body
          end
        end
end