lib/rapnd/daemon.rb in rapnd-0.2.2 vs lib/rapnd/daemon.rb in rapnd-0.2.3
- old
+ new
@@ -45,24 +45,26 @@
return @sock, @ssl
end
def run!
- message = @redis.blpop(self.queue, 1)
- if message
- notification = Rapnd::Notification.new(Marshal.load(message.last))
- self.connect! unless self.connected
- @logger.info "Sending Apple: #{notification.json_payload}"
- self.apple.write(notification.to_bytes)
+ loop do
+ begin
+ message = @redis.blpop(self.queue, 1)
+ if message
+ notification = Rapnd::Notification.new(Marshal.load(message.last))
+ self.connect! unless self.connected
+ @logger.info "Sending Apple: #{notification.json_payload}"
+ self.apple.write(notification.to_bytes)
+ end
+ rescue Exception => e
+ if e.class == Interrupt || e.class == SystemExit
+ @logger.info "Shutting down..."
+ exit(0)
+ end
+ Airbrake.notify(e, {:environment_name => self.queue }) if @airbrake
+ @logger.error "Encountered error: #{e}"
+ end
end
- self.run!
- rescue Exception => e
- if e.class == Interrupt || e.class == SystemExit
- @logger.info "Shutting down..."
- exit(0)
- end
- Airbrake.notify(e, {:environment_name => self.queue }) if @airbrake
- @logger.error "Encountered error: #{e}"
- retry
end
end
end
\ No newline at end of file