summaryrefslogtreecommitdiff
path: root/lib/tapicero/loop.rb
blob: 9c06e52fe9b12d35133654f6a5d0375718ac4391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Tapicero
  class Loop
    def listen(db_name)
      loop do
        begin
          users = CouchRest::Changes.new(db_name)
          UserEventHandler.new(users)
          users.listen
          Tapicero.logger.info('Lost contact with couchdb, will try again in 10 seconds')
          sleep 10
        rescue SystemCallError => exc
          Tapicero.logger.info('Problem connecting to couchdb (#{exc}). Will try again in 10 seconds.')
          sleep 10
          retry
        end
      end
    end
  end
end