lib/yogi_berra/catcher.rb in yogi_berra-0.1.1 vs lib/yogi_berra/catcher.rb in yogi_berra-0.1.3
- old
+ new
@@ -10,15 +10,16 @@
class << self
def load_db_settings(config_file = nil)
if config_file
database_config = config_file
- elsif defined?(Rails)
- database_config = "#{Rails.root}/config/yogi.yml"
+ elsif defined?(::Rails)
+ database_config = Rails.root ? "#{Rails.root}/config/yogi.yml" : "config/yogi.yml"
else
YogiBerra::Logger.log("No config file specified!", :error)
end
+
if database_config
begin
File.open(database_config, 'r') do |f|
yaml_file = YAML.load(f)
@@settings = yaml_file["#{environment}"] if yaml_file
@@ -62,9 +63,10 @@
rescue Timeout::Error => timeout_error
YogiBerra::Logger.log("Couldn't connect to the mongo database timeout on host: #{host} port: #{port}.\n #{timeout_error.inspect}", :error)
retry
rescue => error
YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.\n #{error.inspect}", :error)
+ sleep 1
retry
end
@@connection = @@mongo_client[database]
if username && password
\ No newline at end of file