日期:2014-05-16 浏览次数:20538 次
#!/usr/bin/env ruby require File.expand_path('../../config/environment', __FILE__) def seek_queue queue_name = Settings.queue.packapp.ios BUNNY.start payload = BUNNY.queue(queue_name).pop[:payload] if payload == :queue_empty BUNNY.stop sleep 5 else conn = ActiveRecord::Base.connection begin conn.reconnect! unless conn.active? rescue ActiveRecord::StatementInvalid => e sleep 10 retry end # ... BUNNY.stop end end loop do begin seek_queue rescue Bunny::ServerDownError => e sleep 60 retry end end