Sha256: 55bf5bf89ba16ea1772ab6eb06ae0f9b145ce22c5f846f477d0d2f87ae1456c3
Contents?: true
Size: 773 Bytes
Versions: 7
Compression:
Stored size: 773 Bytes
Contents
require 'yaml' module DaemonKit # Thin wrapper around the amqp gem, specifically designed to ease # configuration of a AMQP consumer daemon and provide some added # simplicity class AMQP @@instance = nil class << self def instance @instance ||= new end private :new def run(&block) instance.run(&block) end end def initialize( config = {} ) @config = DaemonKit::Config.load('amqp').to_h( true ) end def run(&block) # Ensure graceful shutdown of the connection to the broker DaemonKit.trap('INT') { ::AMQP.stop { ::EM.stop } } DaemonKit.trap('TERM') { ::AMQP.stop { ::EM.stop } } # Start our event loop ::AMQP.start(@config, &block) end end end
Version data entries
7 entries across 7 versions & 2 rubygems