Skip to content
Browse files

if disconnect fails, still try to reconnect to db

  • Loading branch information...
1 parent fbb11b7 commit 9e7defdb9ec0f8e24d047d1f2b0b0bc9e774e556 @tompesman committed Mar 15, 2013
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/push/daemon/database_reconnectable.rb
View
9 lib/push/daemon/database_reconnectable.rb
@@ -40,8 +40,13 @@ def database_connection_lost(name)
end
def reconnect_database
- ActiveRecord::Base.clear_all_connections!
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV['RAILS_ENV']])
+ begin
+ ActiveRecord::Base.clear_all_connections!
+ rescue
+ Push::Daemon.logger.error("ActiveRecord::Base.clear_all_connections! failed")
+ ensure
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV['RAILS_ENV']])
+ end
end
def check_database_is_connected

0 comments on commit 9e7defd

Please sign in to comment.
Something went wrong with that request. Please try again.