Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-01-28 14:23:37 +0300
committerRémy Coutable <remy@rymai.me>2016-01-28 14:23:37 +0300
commit55ab92c00bb79a951dea477d59e440c80dc96f91 (patch)
treed4a534caf13a248778b070c2953b9135f6883b56 /lib/gitlab/current_settings.rb
parent869b4d7c6ad5c025f310eeecce7293bf5bbc4926 (diff)
Use ActiveRecord::Base.connection.active? and rescue any exception in connect_to_db?
This ensures that rake tasks that don't need a DB connection can be run without one.
Diffstat (limited to 'lib/gitlab/current_settings.rb')
-rw-r--r--lib/gitlab/current_settings.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index e66e7768f2b..a6b2f14521c 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -41,8 +41,11 @@ module Gitlab
private
def connect_to_db?
+ # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
+ active_db_connection = ActiveRecord::Base.connection.active? rescue false
+
ENV['USE_DB'] != 'false' &&
- ActiveRecord::Base.connection_pool.active_connection? &&
+ active_db_connection &&
ActiveRecord::Base.connection.table_exists?('application_settings')
rescue ActiveRecord::NoDatabaseError