-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.rb
More file actions
104 lines (80 loc) · 3.06 KB
/
Copy pathservice.rb
File metadata and controls
104 lines (80 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'rubygems'
require 'aws/s3'
require 'build/maven.rb'
def packageForDeployment( conn,warDest )
modifyJettyEnv( conn )
sh "mvn package"
restoreJettyEnv()
sh "mkdir -p deployment"
sh "cp target/"+warDest+" deployment/"
return "deployment/"+warDest
end
def regularDeployment( connection, productionWar, artifactId )
Rake::Task['clean'].invoke
localWar = packageForDeployment( connection,productionWar )
results = uploadWar(localWar)
puts "your file has been uploaded to bucket: sr-staging, key :"+results[0]+"\n"
label = "sr-"+results[1]
source = "sr-staging/"+results[0]
sh "elastic-beanstalk-create-application-version -a "+artifactId+" -l "+label+" -c -s "+source
sh "elastic-beanstalk-update-application-version -a "+artifactId+" -l "+label
end
def startupDeployment( connection, productionWar,ebEnv, artifactId )
Rake::Task['clean'].invoke
sh "elastic-beanstalk-create-application -a "+artifactId
sh "elastic-beanstalk-create-configuration-template -a "+artifactId+" -t "+artifactId
localWar = packageForDeployment( connection ,productionWar )
results = uploadWar(localWar)
label = "sr-"+results[1]
source = "sr-staging/"+results[0]
sh "elastic-beanstalk-create-application-version -a "+artifactId+" -l "+label+" -c -s "+source
sh "elastic-beanstalk-create-environment -a "+artifactId+" -t "+artifactId+" -e "+ebEnv+" -l "+label
end
def shutdownDeployment( ebEnv, artifactId )
sh "elastic-beanstalk-delete-environment-configuration -e "+ebEnv+" -a "+artifactId
sh "elastic-beanstalk-delete-configuration-template -t "+artifactId+" -a "+artifactId
sh "elastic-beanstalk-terminate-environment -e "+ebEnv
sh "elastic-beanstalk-delete-application -a "+artifactId
end
def upload( file )
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
)
AWS::S3::S3Object.store(file, open(file), 'sr-staging')
return true
end
desc "upload a sample file to s3"
task :upload, :arg1 do | t,arg |
puts "uploading: "+arg.arg1
upload( arg.arg1 )
puts "uploaded: "+arg.arg1
end
require 'date'
require 'time'
def uploadWar( warfile )
d = Time.new
timestring = d.strftime("%Y%m%d%H%M%S")
firstchunk = warfile.split(".war")[0]
newfilename = firstchunk + "-" + timestring + ".war"
sh "cp "+warfile+" "+newfilename
upload(newfilename)
return [newfilename,timestring]
end
JETTY_WEB="src/main/webapp/WEB-INF/jetty-web.xml"
def modifyJettyEnv(connectionName)
p = projectInfo()
version = p[0]
scalaVersion = [1]
artifactId = p[2]
groupId = p[3]
packaging = p[4]
productionWar = artifactId+"-"+version+"."+packaging
toAdd="<Set name=\"war\"><SystemProperty name=\"jetty.home\" default=\".\"/>/webapps/"+productionWar+"</Set><Set name=\"connectorNames\"><Array type=\"String\"><Item>"+connectionName+"</Item></Array></Set></Configure>"
sh "cp "+JETTY_WEB+" tmp.xml"
sh "cat tmp.xml | sed \'s#</Configure># #' > "+JETTY_WEB
File.open(JETTY_WEB, 'a') {|f| f.write(toAdd) }
end
def restoreJettyEnv()
sh "mv tmp.xml "+JETTY_WEB
end