Created
June 19, 2013 08:33
-
-
Save ulfurinn/5812658 to your computer and use it in GitHub Desktop.
deploying with hooks and amqp
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
#!/usr/bin/env ruby | |
require "dante" | |
require "amqp" | |
require "oj" | |
$0 = "My project generator" | |
Dir.chdir "/var/www/my-project" | |
Dante.run "my-project", pid_path: '/var/www/my-project-generator.pid', user: 'www-data', group: 'www-data' do | |
EM.run do | |
connection = AMQP.connect host: "my.broker.host", vhost: "/my-vhost", user: "my-user", password: "my-password" | |
channel = AMQP::Channel.new connection | |
queue = channel.queue "my-project", auto_delete: true | |
queue.subscribe do |payload| | |
message = Oj.load payload | |
case message["action"] | |
when "generate" | |
`my-deploy-script` | |
end | |
end | |
end | |
end |
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
#!/usr/bin/env ruby | |
require "amqp" | |
EM.run do | |
connection = AMQP.connect(host: 'my.broker.host', vhost: '/my-vhost', user: 'my-user', password: 'my-password') | |
channel = AMQP::Channel.new connection | |
ex = channel.direct "" | |
ex.publish '{"action":"generate"}', routing_key: "my-project" do | |
connection.disconnect { EM.stop } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment