summaryrefslogtreecommitdiff
path: root/lib/tapicero_daemon.rb
blob: e38a4ad3ec44a15e27bae4f6db59c0b6bcde55ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#
# This file should not be required directly. Use the wrapper in /bin
# instead or run this using daemons:
#
#  Daemons.run('tapicero_daemon.rb')
#

require 'tapicero'

module Tapicero
  Tapicero.logger.info "Observing #{Config.couch_host_without_password}"
  Tapicero.logger.info "Tracking #{Config.users_db_name}"
  # stream   = CouchStream.new(Config.couch_host + '/' + Config.users_db_name)
  db = CouchRest.new(Config.couch_host).database(Config.users_db_name)
  users = CouchChanges.new(db, Config.seq_file)

  users.created do |hash|
    Tapicero.logger.debug "Created user " + hash['id']
    db = UserDatabase.new(Config.couch_host, Config.db_prefix + hash['id'])
    db.create
    db.secure(Config.security)
  end

  users.listen
end