diff options
author | elijah <elijah@riseup.net> | 2014-12-14 18:56:14 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-12-14 18:56:14 -0800 |
commit | 97c460cd1133c18fd82a649253db755a38bea0ed (patch) | |
tree | e06e7c7faef7ce9e327f2b3031122bd47df5a241 /lib/tapicero_daemon.rb | |
parent | 92db2c6e6210a860a4de4baf8033428fbe72b7cc (diff) |
try to create the db many times until it exists
Diffstat (limited to 'lib/tapicero_daemon.rb')
-rw-r--r-- | lib/tapicero_daemon.rb | 16 |
1 files changed, 11 insertions, 5 deletions
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 |