summaryrefslogtreecommitdiff
path: root/lib/tapicero_daemon.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tapicero_daemon.rb')
-rw-r--r--lib/tapicero_daemon.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 86f924e..26f8e00 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -5,23 +5,19 @@
# Daemons.run('tapicero_daemon.rb')
#
require 'tapicero'
+require 'tapicero/loop'
require 'extends/couchrest'
require 'tapicero/user_event_handler'
module Tapicero
module Daemon
- while true
- 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
+ users_thread = Thread.new do
+ Tapicero::Loop.new.listen('users')
end
+ tmp_users_thread = Thread.new do
+ Tapicero::Loop.new.listen('tmp_users')
+ end
+ users_thread.join
+ tmp_users_thread.join
end
end