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