Sha256: efc558b28af1b0b520eeeaab7da16908acd1c61f2bdc67bfe38fd4cd5afc7dea

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

$stderr.puts 'loading roo_on_rails railtie'

module RooOnRails
  class Railtie < Rails::Railtie
    initializer 'roo_on_rails.default_env' do
      $stderr.puts 'initializer roo_on_rails.default_env'
      Dotenv.load File.expand_path('../default.env', __FILE__)
    end

    # initializer 'roo_on_rails.print_env' do
    #   ENV.to_a.sort.each do |k,v|
    #     puts "#{k}: #{v}"
    #   end
    # end

    initializer 'roo_on_rails.new_relic' do
      $stderr.puts 'initializer roo_on_rails.new_relic'

      license_key = ENV['NEW_RELIC_LICENSE_KEY']

      if %w[ test development ].exclude?(Rails.env.to_s) and license_key == 'override-me'
        abort 'Aborting: NEW_RELIC_LICENSE_KEY must be set in production environments'
      end
       
      if license_key.nil?
        abort 'Aborting: NEW_RELIC_LICENSE_KEY is required'
      end

      path = %w[newrelic.yml config/newrelic.yml].map { |p|
        Pathname.new(p) 
      }.find(&:exist?)
      if path
        abort "Aborting: newrelic.yml detected in '#{path.parent.realpath}', should not exist"
      end

      require 'newrelic_rpm'
      ::NewRelic::Agent.manual_start unless Rails.env.test?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roo_on_rails-1.1.0 lib/roo_on_rails/railtie.rb
roo_on_rails-1.0.2 lib/roo_on_rails/railtie.rb