Skip to content

Instantly share code, notes, and snippets.

@jondeandres
Forked from Evangenieur/launch.sh
Created January 10, 2013 00:31
Show Gist options
  • Save jondeandres/4498329 to your computer and use it in GitHub Desktop.
Save jondeandres/4498329 to your computer and use it in GitHub Desktop.
#!/bin/bash
thin start -p 3000 -R test.ru
require "sinatra/base"
require "amqp"
class Test < Sinatra::Base
def amqp &blk
if ! AMQP.connection
AMQP.connection = AMQP.connect "amqp://myAMQPserver.com"
end
if ! AMQP.connection.connected?
AMQP.connection.register_connection_callback do
raise "Error couldn't connect" unless AMQP.connection.connected?
blk.()
end
else
blk.()
end
end
get "/" do
amqp do
p "publishing"
MQ.queue("test_thin_sinatra_AMQP", :durable => true).publish("coucou")
end
"o/"
end
end
run Test.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment