From 407a08f64413bdae43fe95f173e207093f54949c Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 3 May 2013 09:42:07 +0200 Subject: [PATCH] only use the db follower if use_database_follower is set in the config --- lib/travis/api/app.rb | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) 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'