diff options
author | Marin Jankovski <marin@gitlab.com> | 2015-09-02 00:14:57 +0300 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2015-09-02 00:14:57 +0300 |
commit | 308c6428aef2a46b0370a24d85a97b0e133283a8 (patch) | |
tree | 3b05743958cb2aa7b2fc50df8b4f16202cdd6b22 /lib | |
parent | afb2e6f48548ce3c5dc3279265bfd8b9dedf9e0d (diff) | |
parent | 3a8773fb2f86757ce0a061ef6476b7d91bcb6259 (diff) |
Merge branch 'use_db_for_application_settings' into 'master'
Check if database connection exists when loading application settings
!1217 broke omnibus-gitlab nightly builds. In omnibus-gitlab we precompile assets without a running database.
See merge request !1230
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/current_settings.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 7ad3ed8728f..0ea1b6a2f6f 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -4,7 +4,7 @@ module Gitlab key = :current_application_settings RequestStore.store[key] ||= begin - if ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings') + if connect_to_db? ApplicationSetting.current || ApplicationSetting.create_from_defaults else fake_application_settings @@ -26,5 +26,17 @@ module Gitlab import_sources: Settings.gitlab['import_sources'] ) end + + private + + def connect_to_db? + use_db = if ENV['USE_DB'] == "false" + false + else + true + end + + use_db && ActiveRecord::Base.connection.active? && ActiveRecord::Base.connection.table_exists?('application_settings') + end end end |