summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-03-17 15:03:33 -0700
committerelijah <elijah@riseup.net>2015-03-17 15:03:33 -0700
commit0d00d6a8f6eaf15d2a3e5125e599f9735c85d5d6 (patch)
tree44046ba1108870d7b5ffbb75ba01eef6cf8866ee /lib
parent413b42ea36b5e0406187a881183f4648d8534ec5 (diff)
added support for tmp_users db. not backward compatible with prior config files (seq_file changed to seq_dir)
Diffstat (limited to 'lib')
-rw-r--r--lib/tapicero/loop.rb19
-rw-r--r--lib/tapicero/version.rb2
-rw-r--r--lib/tapicero_daemon.rb20
3 files changed, 28 insertions, 13 deletions
diff --git a/lib/tapicero/loop.rb b/lib/tapicero/loop.rb
new file mode 100644
index 0000000..9c06e52
--- /dev/null
+++ b/lib/tapicero/loop.rb
@@ -0,0 +1,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
diff --git a/lib/tapicero/version.rb b/lib/tapicero/version.rb
index 759b47b..83ed50f 100644
--- a/lib/tapicero/version.rb
+++ b/lib/tapicero/version.rb
@@ -1,5 +1,5 @@
module Tapicero
- VERSION = "0.6"
+ VERSION = "0.6.1"
REQUIRE_PATHS = ['lib']
FLAGS = []
CONFIGS = ['config/default.yaml', '/etc/leap/tapicero.yaml']
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