dploy 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,23 +14,30 @@ module Dploy
14
14
 
15
15
  def deploy
16
16
  deploy_data = JSON.parse((RestClient.post "http://#{@server}/deploy", { :project => @project, :environment => @environment, :version => @version }.to_json, :content_type => :json, :accept => :json))
17
- get_deploy_logs(deploy_data['id'])
17
+ monitor_deploy(deploy_data['id'])
18
18
  end
19
19
 
20
- def get_deploy_logs(deploy_id)
20
+ def monitor_deploy(deploy_id)
21
+ failed = false
21
22
  finished = false
22
- start_id = "000000000000000000000000"
23
+ last_id = "000000000000000000000000"
23
24
 
24
25
  while not finished
25
- logs = JSON.parse(RestClient.get( "http://#{@server}/logs/#{deploy_id}/?start_id=#{start_id}", :accept => :json), :symbolize_keys => true)
26
+ logs = JSON.parse(RestClient.get( "http://#{@server}/logs/#{deploy_id}/?start_id=#{last_id}", :accept => :json), :symbolize_names => true)
26
27
  logs.each do |row|
27
- puts "!!!!!!!!!!!!!!!!!!!SOME LOGS!!!!!!!!!!!!!!!!!!1"
28
- puts "#{row[:log_type]} #{row[:message]}"
28
+ puts "#{row[:log_type]}: #{row[:message]}"
29
29
  STDOUT.flush
30
- finished = true if row[:log_type] == "completion"
30
+ last_id = row[:_id]
31
+ if row[:log_type] == "completion"
32
+ finished = true
33
+ if row[:status] == "failure"
34
+ failed = true
35
+ end
36
+ end
31
37
  end
32
38
  sleep 1
33
39
  end
40
+ exit 1 if failed
34
41
  end
35
42
 
36
43
  end
@@ -50,14 +50,15 @@ module Dploy
50
50
 
51
51
  #Run Chef client
52
52
  @log.debug("Running Chef Client for #{node_name} (#{instance.dns_name})")
53
- ShellCmd.run("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{DPLOY_CONFIG['ec2_ssh_key_path']} ubuntu@#{instance.dns_name} sudo chef-client", @deploy_data[:id])
53
+ ShellCmd.run("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i #{DPLOY_CONFIG['ec2_ssh_key_path']} ubuntu@#{instance.dns_name} sudo chef-client", @log)
54
+
54
55
 
55
56
  #TODO Test
56
57
 
57
58
  @log.completion("Completed",{:status => "Success"})
58
59
  end
59
- rescue Exception
60
- @log.error($!)
60
+ rescue
61
+ @log.error("#{$!}")
61
62
  @log.completion("Failed",{:status => "failure"})
62
63
  end
63
64
  end
@@ -1,28 +1,33 @@
1
1
  require 'pty'
2
2
 
3
3
  module Dploy
4
-
5
- class ShellCmd
6
-
7
- def self.run(command, log)
8
- PTY.spawn(command) do |output, input, pid|
9
- begin
10
- while !PTY.check(pid)
11
- if log != nil
12
- line = output.gets
13
- if line.upcase.include? "ERROR"
14
- log.error(line)
15
- else
16
- log.debug(line)
17
- end
18
- end
19
- end
20
- rescue Errno::EIO
21
- puts "end"
22
- end
23
- end
24
- end
25
-
26
- end
27
-
4
+
5
+ class ShellCmd
6
+
7
+ def self.run(command, log = nil)
8
+ error_found = false
9
+ PTY.spawn(command) do |output, input, pid|
10
+ begin
11
+ while result = !PTY.check(pid)
12
+ if log != nil
13
+ line = output.gets
14
+ if line.upcase.include? "ERROR"
15
+ log.error(line)
16
+ error_found = true
17
+ else
18
+ log.debug(line)
19
+ end
20
+ end
21
+ end
22
+ rescue Errno::EIO
23
+ #no more output
24
+ end
25
+ puts "*" * 200 if error_found || $?.exitstatus != 0 if $? != nil
26
+ raise "command: #{command} failed!" if error_found || $?.exitstatus != 0 if $? != nil
27
+ end
28
+ end
29
+ end
28
30
  end
31
+
32
+
33
+
@@ -1,3 +1,3 @@
1
1
  module Dploy
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-04 00:00:00.000000000Z
12
+ date: 2011-11-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- requirement: &25285820 !ruby/object:Gem::Requirement
16
+ requirement: &18070520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25285820
24
+ version_requirements: *18070520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: chef
27
- requirement: &25282440 !ruby/object:Gem::Requirement
27
+ requirement: &18068340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25282440
35
+ version_requirements: *18068340
36
36
  description: deploymoent module for chef and aws
37
37
  email:
38
38
  - james@stylesaint.com