Created
March 24, 2014 08:30
-
-
Save krishna-shilpakar/9736370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "amqp" | |
EventMachine.run do | |
connection = AMQP.connect | |
channel = AMQP::Channel.new(connection) | |
requests_queue = channel.queue("citizen40.install.app", :exclusive => true, :auto_delete => true) | |
requests_queue.subscribe(:ack => true) do |metadata, payload| | |
puts "[requests] Got a request #{metadata.message_id}. Sending a reply..." | |
# codes that will install the softwares. | |
# For example | |
# shellout = "apt-get install #{data[:app]" | |
channel.default_exchange.publish("citizen40.install.app.acknowledge, | |
:routing_key => metadata.reply_to, | |
:correlation_id => metadata.message_id, | |
:mandatory => true) | |
metadata.ack | |
end | |
Signal.trap("INT") { connection.close { EventMachine.stop } } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment