diff --git a/drb_counter/drb_counter.rb b/drb_counter/drb_counter.rb index fd476846..a3adf4b6 100755 --- a/drb_counter/drb_counter.rb +++ b/drb_counter/drb_counter.rb @@ -3,6 +3,8 @@ # See Dockerfile for run instructions require 'rubygems' require 'drb/drb' +require 'erb' +require 'couchrest' #require 'pry' #require File.expand_path('../lib/in_memory_q_counter', File.dirname(__FILE__)) # This is a non thread safe replacement for the @@ -67,7 +69,8 @@ class InMemoryQCounter couch_settings_path = 'config/couchdb.yml' puts "Couch settings path: #{couch_settings_path}" puts "Environment: #{environment.inspect}" - couch_settings = YAML.load_file(couch_settings_path)[environment] + #couch_settings = YAML.load_file(couch_settings_path)[environment] + couch_settings = YAML.safe_load(ERB.new(File.read(couch_settings_path)).result, [Symbol], [], ['default'])[environment] database = couch_settings['database'] db = CouchRest.database(database) # for debug: db = CouchPotato.database.couchrest_database design_doc = "_design/order_counter" @@ -75,7 +78,7 @@ class InMemoryQCounter tries = 0 begin view_result = db.view(view_path, reduce: true, group: true, group_level: 2) - rescue RestClient::ResourceNotFound => e + rescue CouchRest::NotFound => e puts "Database view #{view_path} not found" design_doc_path = File.expand_path('../couchdb_design.yml', __FILE__) doc = YAML.load_file design_doc_path @@ -107,5 +110,6 @@ class InMemoryQCounter end drb_port = 9022 environment = (%w[production staging development test] & [ENV['DRB_ENV']]).first || 'development' -DRb.start_service "druby://:#{drb_port}", InMemoryQCounter.new(reload_stats: environment == 'production', environment: environment) +#InMemoryQCounter.new(reload_stats: true, environment: environment) +DRb.start_service "druby://:#{drb_port}", InMemoryQCounter.new(reload_stats: true, environment: environment) DRb.thread.join