cody 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/cody/cli.rb +1 -1
- data/lib/cody/help/logs.md +2 -2
- data/lib/cody/tailer.rb +39 -12
- data/lib/cody/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb76da799abde0f40871e41fa9ed6bbcaf655c9b2f5ed4646d8e7288af31d7a8
|
4
|
+
data.tar.gz: 7c7c53ed681e4cc7f6cb9441394f6f61c77cc91d4395e408861e73ab1066f0d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fdb64cd0da4df5de7de9bd90a418ce94f0768d98d483a557909e4090634591cd5f5cbfb40589a75676b3648f1e9edde197578f3f75cf70fa7744811f62b0640
|
7
|
+
data.tar.gz: fa7410c0edaf38296f01821d544df72f68ad8035265ad891ac31005a4e66877eb2a07ac7e48f70d019126395f6b5cb50da3976afdad0dd12f20f6863f4f7a6c1
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.8.3]
|
7
|
+
- #11 sleep on error for cloudwatch logs
|
8
|
+
- also add `-t` alias for `--type` option
|
9
|
+
|
6
10
|
## [0.8.2]
|
7
11
|
- #9 add cody stop command
|
8
12
|
- #10 add evaluate interface methods
|
data/lib/cody/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module Cody
|
|
11
11
|
register(Init, "init", "init", "Set up initial .cody files.")
|
12
12
|
|
13
13
|
common_options = Proc.new do
|
14
|
-
option :type, desc: "folder to use within .cody folder for different build types"
|
14
|
+
option :type, aliases: "t", desc: "folder to use within .cody folder for different build types"
|
15
15
|
option :stack_name, desc: "Override the generated stack name. If you use this you must always specify it"
|
16
16
|
option :wait, type: :boolean, default: true, desc: "Wait for operation to complete"
|
17
17
|
end
|
data/lib/cody/help/logs.md
CHANGED
@@ -49,7 +49,7 @@
|
|
49
49
|
|
50
50
|
By default, Cody logs searches only 7 days in the past. This is done for speed. If you have an older build and would like to search further in the past. You can use the `--since option`. Example:
|
51
51
|
|
52
|
-
cody logs --since
|
52
|
+
cody logs --since 4w # 4 weeks ago
|
53
53
|
|
54
54
|
The since format is from the [aws-logs gem](https://github.com/tongueroo/aws-logs). Since formats:
|
55
55
|
|
@@ -59,4 +59,4 @@ The since format is from the [aws-logs gem](https://github.com/tongueroo/aws-log
|
|
59
59
|
* d - days
|
60
60
|
* w - weeks
|
61
61
|
|
62
|
-
Since does not support combining the formats. IE: 5m30s.
|
62
|
+
Since does not support combining the formats. IE: 5m30s.
|
data/lib/cody/tailer.rb
CHANGED
@@ -13,11 +13,6 @@ module Cody
|
|
13
13
|
set_trap
|
14
14
|
end
|
15
15
|
|
16
|
-
def find_build
|
17
|
-
resp = codebuild.batch_get_builds(ids: [@build_id])
|
18
|
-
resp.builds.first
|
19
|
-
end
|
20
|
-
|
21
16
|
def run
|
22
17
|
puts "Showing logs for build #{@build_id}"
|
23
18
|
|
@@ -32,16 +27,21 @@ module Cody
|
|
32
27
|
set_log_group_name(build)
|
33
28
|
|
34
29
|
complete = build.build_complete
|
35
|
-
start_cloudwatch_tail unless ENV["CODY_TEST"]
|
36
|
-
sleep 5 if !@@end_loop_signal && !complete && !ENV["CODY_TEST"]
|
37
|
-
end
|
38
30
|
|
39
|
-
|
40
|
-
|
31
|
+
next if ENV["CODY_TEST"]
|
32
|
+
start_cloudwatch_tail
|
33
|
+
sleep 5
|
34
|
+
end
|
41
35
|
|
36
|
+
stop_cloudwatch_tail(build)
|
42
37
|
puts "The build took #{build_time(build)} to complete."
|
43
38
|
end
|
44
39
|
|
40
|
+
def find_build
|
41
|
+
resp = codebuild.batch_get_builds(ids: [@build_id])
|
42
|
+
resp.builds.first
|
43
|
+
end
|
44
|
+
|
45
45
|
def start_cloudwatch_tail
|
46
46
|
return if @cloudwatch_tail_started
|
47
47
|
return unless @log_group_name && @log_stream_name
|
@@ -64,6 +64,35 @@ module Cody
|
|
64
64
|
cw_tail.run
|
65
65
|
end
|
66
66
|
|
67
|
+
def stop_cloudwatch_tail(build)
|
68
|
+
return if ENV["CODY_TEST"]
|
69
|
+
|
70
|
+
# The AwsLogs::Tail.stop_follow! results in a little waiting because it signals to break the polling loop.
|
71
|
+
# Since it's in the middle of the loop process, the loop will finish the sleep 5 first.
|
72
|
+
# So it can pause from 0-5 seconds.
|
73
|
+
#
|
74
|
+
# However, this is sometimes not enough of a pause for CloudWatch to receive and send the logs back to us.
|
75
|
+
# So additionally pause on a failed build so we can receive the final logs at the end.
|
76
|
+
#
|
77
|
+
sleep 10 if complete_failed?(build) # provide extra time for cw tail to report error
|
78
|
+
AwsLogs::Tail.stop_follow!
|
79
|
+
@thread.join if @thread
|
80
|
+
end
|
81
|
+
|
82
|
+
# build.build_status : The current status of the build. Valid values include:
|
83
|
+
#
|
84
|
+
# FAILED : The build failed.
|
85
|
+
# FAULT : The build faulted.
|
86
|
+
# IN_PROGRESS : The build is still in progress.
|
87
|
+
# STOPPED : The build stopped.
|
88
|
+
# SUCCEEDED : The build succeeded.
|
89
|
+
# TIMED_OUT : The build timed out.
|
90
|
+
#
|
91
|
+
def complete_failed?(build)
|
92
|
+
return if ENV["CODY_TEST"]
|
93
|
+
build.build_complete && build.build_status != "SUCCEEDED"
|
94
|
+
end
|
95
|
+
|
67
96
|
# Setting enables start_cloudwatch_tail
|
68
97
|
def set_log_group_name(build)
|
69
98
|
logs = build.logs
|
@@ -111,11 +140,9 @@ module Cody
|
|
111
140
|
@output.join("\n") + "\n"
|
112
141
|
end
|
113
142
|
|
114
|
-
@@end_loop_signal = false
|
115
143
|
def set_trap
|
116
144
|
Signal.trap("INT") {
|
117
145
|
puts "\nCtrl-C detected. Exiting..."
|
118
|
-
@@end_loop_signal = true # useful to control loop
|
119
146
|
exit # immediate exit
|
120
147
|
}
|
121
148
|
end
|
data/lib/cody/version.rb
CHANGED