Class: Outpace

Inherits:
Object
  • Object
show all
Defined in:
lib/outpace.rb

Class Method Summary collapse

Class Method Details

.clojure_profileObject



13
14
15
16
17
18
19
20
# File 'lib/outpace.rb', line 13

def self.clojure_profile
  case ENV['ENVIRONMENT_NAME']
    when 'prod' then 'production'
    when /^qa/ then 'qa'
    when /dev/, nil then 'dev'
    else raise "Unrecognized $ENVIRONMENT_NAME: #{ENV['ENVIRONMENT_NAME'].inspect}"
  end
end

.ensure_aws_credentialsObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/outpace.rb', line 2

def self.ensure_aws_credentials
  raise <<-AWS unless ENV.keys.include?("AWS_ACCESS_KEY_ID") && ENV.keys.include?("AWS_SECRET_ACCESS_KEY")
  You don't seem to have AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY
  AWS

  require 'time'
  raise <<-AWS if ENV["AWS_SECURITY_TOKEN_TIMESTAMP"] && Time.parse(ENV["AWS_SECURITY_TOKEN_TIMESTAMP"]) - Time.now < 0
  You need to run derp authenticate again, your authentication seems to have expired
  AWS
end

.run_jar_with_new_relic(service, jar_file) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/outpace.rb', line 22

def self.run_jar_with_new_relic(service, jar_file)
  ENV["NEW_RELIC_LOG"] = "#{service}.log"
  jvm_opts = []

  case clojure_profile
  when 'production' 
    ENV["NEW_RELIC_APP_NAME"] = service
    jvm_opts << "-Dnewrelic.environment=production"
    jvm_opts << "-javaagent:../clojure/newrelic/newrelic.jar"
  when 'qa' then "_qa"
    ENV["NEW_RELIC_APP_NAME"] = "#{service}_qa"
    jvm_opts << "-Dnewrelic.environment=qa"
  when 'dev'
    ENV["NEW_RELIC_APP_NAME"] = "#{service}_dev"
    jvm_opts << "-Dnewrelic.environment=development"
  end

  puts "Starting #{service}"
  cmd = (["java"] + jvm_opts + ["-jar", jar_file]).join(" ")
  puts "Executing #{cmd}"
  exec cmd
end