7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/zendesk/user_updater_initializer.rb', line 7
def initialize!(conf_dir, kb_apis, logger)
begin
@config = YAML.load(ERB.new(File.read("#{conf_dir}/zendesk.yml")).result)
rescue Errno::ENOENT
logger.warn "Unable to find the config file #{conf_dir}/zendesk.yml"
return
end
logger.log_level = Logger::DEBUG if (@config[:logger] || {})[:debug]
client = ZendeskAPI::Client.new do |config|
config.url = "https://#{@config[:zendesk][:subdomain]}.zendesk.com/api/v2"
config.username = @config[:zendesk][:username]
config.password = @config[:zendesk][:password]
config.token = @config[:zendesk][:token]
config.retry = true if @config[:zendesk][:retry]
config.logger = logger
end
require 'active_record'
require 'active_record/bogacs'
require 'arjdbc'
::ActiveRecord::ConnectionAdapters::ConnectionHandler.connection_pool_class = ::ActiveRecord::Bogacs::FalsePool
db_config = @config[:database] || {
:adapter => :mysql,
:data_source => Java::JavaxNaming::InitialContext.new.lookup('killbill/osgi/jdbc'),
:configure_connection => false
}
ActiveRecord::Base.establish_connection(db_config)
@updater = UserUpdater.new(client, kb_apis, logger)
end
|