Sha256: 76d39490508f9cf794d0909ecc513434444a986d645ad867de3108d73e198fb6

Contents?: true

Size: 725 Bytes

Versions: 4

Compression:

Stored size: 725 Bytes

Contents

require "yaml"

module Juggernaut
  module Rails
    class <<self
      attr_writer :hosts
      
      def default_options
        @default_options ||= {
          :config_path => File.join(::Rails.root, 'config', 'juggernaut.yml'),
          :log_path => File.join(::Rails.root, 'log', 'juggernaut.log'),
          :pid_path => File.join(::Rails.root, 'tmp', 'pids', 'juggernaut.5001.pid')
        }
      end
      
      def hosts
        @hosts ||= YAML::load(ERB.new(IO.read("#{::Rails.root}/config/juggernaut_hosts.yml")).result)[:hosts].select {|h| !h[:environment] or h[:environment] == ::Rails.env.to_sym }
      end
      
      def random_host
        hosts[rand(hosts.length)]        
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
juggernaut_rails-0.6.2 lib/juggernaut/rails.rb
juggernaut_rails-0.6.1 lib/juggernaut/rails.rb
juggernaut_rails-0.6.0 lib/juggernaut/rails.rb
juggernaut_rails-0.5.9 lib/juggernaut/rails.rb