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.
- data/lib/dploy/client.rb +14 -7
- data/lib/dploy/deployer.rb +4 -3
- data/lib/dploy/shell_command.rb +29 -24
- data/lib/dploy/version.rb +1 -1
- metadata +6 -6
data/lib/dploy/client.rb
CHANGED
@@ -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
|
-
|
17
|
+
monitor_deploy(deploy_data['id'])
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
20
|
+
def monitor_deploy(deploy_id)
|
21
|
+
failed = false
|
21
22
|
finished = false
|
22
|
-
|
23
|
+
last_id = "000000000000000000000000"
|
23
24
|
|
24
25
|
while not finished
|
25
|
-
logs = JSON.parse(RestClient.get( "http://#{@server}/logs/#{deploy_id}/?start_id=#{
|
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 "
|
28
|
-
puts "#{row[:log_type]} #{row[:message]}"
|
28
|
+
puts "#{row[:log_type]}: #{row[:message]}"
|
29
29
|
STDOUT.flush
|
30
|
-
|
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
|
data/lib/dploy/deployer.rb
CHANGED
@@ -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", @
|
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
|
60
|
-
@log.error($!)
|
60
|
+
rescue
|
61
|
+
@log.error("#{$!}")
|
61
62
|
@log.completion("Failed",{:status => "failure"})
|
62
63
|
end
|
63
64
|
end
|
data/lib/dploy/shell_command.rb
CHANGED
@@ -1,28 +1,33 @@
|
|
1
1
|
require 'pty'
|
2
2
|
|
3
3
|
module Dploy
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
+
|
data/lib/dploy/version.rb
CHANGED
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.
|
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-
|
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: &
|
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: *
|
24
|
+
version_requirements: *18070520
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: chef
|
27
|
-
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: *
|
35
|
+
version_requirements: *18068340
|
36
36
|
description: deploymoent module for chef and aws
|
37
37
|
email:
|
38
38
|
- james@stylesaint.com
|