From 97c460cd1133c18fd82a649253db755a38bea0ed Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 14 Dec 2014 18:56:14 -0800 Subject: try to create the db many times until it exists --- lib/tapicero_daemon.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/tapicero_daemon.rb') diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb index 9eb342b..86f924e 100644 --- a/lib/tapicero_daemon.rb +++ b/lib/tapicero_daemon.rb @@ -11,11 +11,17 @@ require 'tapicero/user_event_handler' module Tapicero module Daemon while true - users = CouchRest::Changes.new('users') - UserEventHandler.new(users) - users.listen - Tapicero.logger.info('Lost contact with couchdb, will try again in 10 seconds') - sleep 10 + begin + users = CouchRest::Changes.new('users') + 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 -- cgit v1.2.3