@@ -16,6 +16,8 @@ semver = require 'semver'
1616request = require ' request'
1717ec2 = new AWS.EC2 ()
1818elb = new AWS.ELB ()
19+ runAfter = (time ,fn ) ->
20+ setTimeout fn,time
1921
2022
2123class Release
@@ -62,7 +64,7 @@ class Release
6264
6365 @ registerInstancesWithPrefix = (prefix , callback )->
6466 fetchInstancesWithPrefix prefix, (err ,instances )->
65- # log instances
67+ log instances
6668 elb .registerInstancesWithLoadBalancer
6769 Instances : instances
6870 LoadBalancerName : " koding-prod-deployment"
@@ -164,7 +166,6 @@ class Deploy
164166 callback null
165167
166168 @ createInstances = (options = {}, callback ) ->
167- log ' yo'
168169 params = options .params
169170
170171 iamcalledonce = 0
@@ -192,51 +193,6 @@ class Deploy
192193
193194 callback null , data
194195
195- # data.Instances.forEach (instance)->
196- # log instance.InstanceId
197-
198- # Deploy.tagInstances data,(err,res)->
199-
200- # instanceIds = (InstanceId for InstanceId in data.Instances)
201- # log "instanceIds:",InstanceIds
202- # params =
203- # InstanceIds : InstanceIds
204-
205-
206- # timer = setInterval ->
207-
208- # ec2.describeInstanceStatus params,(err,data)->
209- # if err then log err
210- # else
211- # states.instanceState = data?.InstanceStatuses?[0]?.InstanceState?.Name
212- # states.reachability = data?.InstanceStatuses?[0]?.InstanceStatus?.Details?[0]?.Status
213-
214- # ec2.describeInstances params,(err,data)->
215- # if err then log err
216- # else
217- # states.initialState = data?.Reservations?[0]?.Instances?[0]?.State?.Name
218- # states.final = data?.Reservations?[0]?.Instances?[0]
219- # else
220- # log "instance is now running with IP:", IP = states.final.PublicIpAddress
221- # clearInterval timer
222- # ,5000
223-
224- # @deployAndConfigure = (options,callback)->
225-
226-
227- # Deploy.createInstance options,(err,result) ->
228- # deployStart = new Date()
229- # {conn} = result
230-
231- # conn.exec options.buildScript, (err, stream) ->
232- # throw err if err
233- # conn.listen "[configuring #{result.instanceName}]", stream,->
234- # throw err if err
235- # # delete result.conn
236- # # log result.instanceData
237- # log "Deployment of #{result.instanceName} took: #{timethat.calc deployStart,new Date()}"
238- # conn.end()
239- # callback null, result
240196
241197 @ deployTest = (options ,callback )->
242198
@@ -308,8 +264,8 @@ if argv.deploy
308264
309265
310266 options =
311- boxes : argv .boxes or 5
312- boxtype : argv .boxtype or " t2.medium "
267+ boxes : argv .boxes or 2
268+ boxtype : argv .boxtype or " t2.micro "
313269 versiontype : argv .versiontype or " patch" # available options major, premajor, minor, preminor, patch, prepatch, or prerelease
314270 config : argv .config or " prod" # prod | staging | sandbox
315271 version : argv .version or version
@@ -326,12 +282,12 @@ if argv.deploy
326282
327283 UserData = new Buffer (KONFIG .runFile ).toString (' base64' )
328284
329- options =
285+ deployOptions =
330286 params :
331287 ImageId : " ami-864d84ee" # Amazon ubuntu 14.04 "ami-1624987f" # Amazon Linux AMI x86_64 EBS
332288 InstanceType : options .boxtype
333- MinCount : 2
334- MaxCount : 2
289+ MinCount : options . boxes
290+ MaxCount : options . boxes
335291 SubnetId : " subnet-b47692ed"
336292 KeyName : " koding-prod-deployment"
337293 UserData : UserData
@@ -343,9 +299,18 @@ if argv.deploy
343299
344300
345301
346- Deploy .createInstances options,(err ,res )->
302+ Deploy .createInstances deployOptions,(err ,res )->
303+
304+ runAfter 5 ,Release .registerInstancesWithPrefix options .hostname ,(err ,res )->
305+ log " ------------------------------------------------------------------"
306+ log " Deployment complete, give it 5 minutes... (depends on the boxtype)"
307+ log " ------------------------------------------------------------------"
308+ log " ELB: koding-prod-deployment-109498171.us-east-1.elb.amazonaws.com "
309+ log " ------------------------------------------------------------------"
310+ log " URL: https://koding.io "
311+ log " ------------------------------------------------------------------"
347312
348- log JSON .stringify res,null ,2
313+ # log JSON.stringify res,null,2
349314
350315 # res.Instances.forEach (instance)->
351316 # IP = instance.PublicIpAddress
0 commit comments