diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 34525662..5d887cc3 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -118,21 +118,8 @@ module Travis::Api def self.setup_travis Travis::Amqp.config = Travis.config.amqp - Travis::Database.connect - if Travis.env == 'production' || Travis.env == 'staging' - # Octopus checks for Rails.env, just hardcode enabled? - Octopus.instance_eval do - def enabled? - true - end - end - ActiveRecord::Base.custom_octopus_connection = false - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = ['production', 'staging'] - end - end + setup_database_connections Travis::Features.start @@ -152,6 +139,26 @@ module Travis::Api end end + def self.setup_database_connections + Travis::Database.connect + + return unless Travis.config.use_database_follower? + + if Travis.env == 'production' || Travis.env == 'staging' + # Octopus checks for Rails.env, just hardcode enabled? + Octopus.instance_eval do + def enabled? + true + end + end + ActiveRecord::Base.custom_octopus_connection = false + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + config.environments = ['production', 'staging'] + end + end + end + def self.load_endpoints Backports.require_relative_dir 'app/middleware' Backports.require_relative_dir 'app/endpoint'