socotra-build 0.3.43 → 0.3.44
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.
- checksums.yaml +4 -4
- data/lib/socotra-build.rb +55 -31
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 197109c5fb557b019df22f43cba84229117e5f6a
|
|
4
|
+
data.tar.gz: f9431064977331ee5655e704133a6c530e4aaa73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0abe5551f4a59406bc1b26af4e819d0f1477ebf445e8b659098922f501376395471acb04a5dc7b71af62cfca3b112f7f113ad4d720eb16819e0c08e31499ae02
|
|
7
|
+
data.tar.gz: 81123c91407bc7c09c74c243a222c9f197b206084bdebc68ee4cdced02bd07a8211b422044dabae26e90184c205da40c276be4139e90fa4ca710efe8b6d04818
|
data/lib/socotra-build.rb
CHANGED
|
@@ -5,20 +5,24 @@ require_relative 's3_uploader'
|
|
|
5
5
|
|
|
6
6
|
def self.safe_retry(cmd, description, error_message="command failed", raise_on_fail=true, log_level="ERROR", log=true, tries=3, timeout=0)
|
|
7
7
|
begin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sleep 5
|
|
12
|
-
retry unless (tries).zero?
|
|
8
|
+
retry_count ||= 1
|
|
9
|
+
if tries == (retry_count)
|
|
10
|
+
last_try = true
|
|
13
11
|
else
|
|
14
|
-
|
|
15
|
-
if raise_on_fail
|
|
16
|
-
raise "ERROR: #{error_message}"
|
|
17
|
-
end
|
|
12
|
+
last_try = false
|
|
18
13
|
end
|
|
14
|
+
|
|
15
|
+
status, output = system_safe(cmd, description, error_message, raise_on_fail=raise_on_fail, log_level=log_level, log=log, print_command=true, retry_exec=true, timeout=timeout, log_file_number=retry_count, last_try=last_try)
|
|
16
|
+
rescue
|
|
17
|
+
sleep 5
|
|
18
|
+
retry if (retry_count += 1) < (tries + 1)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
if last_try and raise_on_fail
|
|
22
|
+
raise
|
|
23
|
+
else
|
|
24
|
+
return status
|
|
25
|
+
end
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
def self.get_sanitized_cmd(cmd)
|
|
@@ -90,19 +94,52 @@ def self.execute_cmd(cmd, timeout, log_out, log_err)
|
|
|
90
94
|
end
|
|
91
95
|
end
|
|
92
96
|
|
|
93
|
-
def self.
|
|
97
|
+
def self.logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_level, error_message)
|
|
98
|
+
|
|
99
|
+
date = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
100
|
+
if log
|
|
101
|
+
puts "#{date} INFO: Logs available here: #{log_err} and #{log_out}"
|
|
102
|
+
else
|
|
103
|
+
puts "#{date} INFO: Logs unavailable due to user settings"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
if not (success or retry_exec)
|
|
107
|
+
puts "#{date} #{log_level}: #{error_message}"
|
|
108
|
+
raise
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if not success and retry_exec
|
|
112
|
+
if last_try and raise_on_fail
|
|
113
|
+
log_level = "ERROR"
|
|
114
|
+
else
|
|
115
|
+
log_level = "WARNING"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
if log
|
|
119
|
+
puts "#{date} #{log_level}: see #{log_out} and #{log_err} for details"
|
|
120
|
+
end
|
|
121
|
+
puts "#{date} #{log_level}: #{error_message}"
|
|
122
|
+
|
|
123
|
+
if not last_try
|
|
124
|
+
raise
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def self.system_safe(cmd=cmd, cmd_description=cmd_description, error_message=error_message, raise_on_fail=true, log_level="ERROR", log=true, print_command=true, retry_exec=false, timeout=0, log_file_number=1, last_try=true)
|
|
94
130
|
start = Time.now.to_i
|
|
95
131
|
|
|
132
|
+
date = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
96
133
|
cmd_sanitized = get_sanitized_cmd(cmd)
|
|
97
134
|
if print_command
|
|
98
|
-
puts "Executing command: #{cmd_sanitized}
|
|
135
|
+
puts "#{date} Executing command: #{cmd_sanitized}"
|
|
99
136
|
else
|
|
100
137
|
puts "Not logging command"
|
|
101
138
|
end
|
|
102
139
|
|
|
103
140
|
if log
|
|
104
|
-
log_out = "logs/#{cmd_description}_out.log"
|
|
105
|
-
log_err = "logs/#{cmd_description}_err.log"
|
|
141
|
+
log_out = "logs/#{cmd_description}_out.log.#{log_file_number}"
|
|
142
|
+
log_err = "logs/#{cmd_description}_err.log.#{log_file_number}"
|
|
106
143
|
else
|
|
107
144
|
log_out = "/dev/null"
|
|
108
145
|
log_err = "/dev/null"
|
|
@@ -112,26 +149,13 @@ def self.system_safe(cmd=cmd, cmd_description=cmd_description, error_message=err
|
|
|
112
149
|
|
|
113
150
|
elapsed = Time.now.to_i - start
|
|
114
151
|
|
|
115
|
-
|
|
152
|
+
date = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
153
|
+
puts "#{date} INFO: #{cmd_description} took #{elapsed} seconds"
|
|
116
154
|
|
|
117
|
-
file = File.open(
|
|
155
|
+
file = File.open(log_out, "rb")
|
|
118
156
|
out = file.read
|
|
119
157
|
|
|
120
|
-
|
|
121
|
-
puts "\tINFO: Logs available here: #{cmd_description}_err.log and #{cmd_description}_out.log\n\n"
|
|
122
|
-
else
|
|
123
|
-
puts "\tINFO: Logs unavailable due to user settings"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
if not success and raise_on_fail
|
|
127
|
-
if retry_exec
|
|
128
|
-
log_level = "WARNING"
|
|
129
|
-
end
|
|
130
|
-
if log
|
|
131
|
-
puts "#{log_level}: see logs/#{cmd_description}_out.log and #{cmd_description}_err.log for details"
|
|
132
|
-
end
|
|
133
|
-
raise "#{log_level}: #{error_message}"
|
|
134
|
-
end
|
|
158
|
+
logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_level, error_message)
|
|
135
159
|
|
|
136
160
|
return success
|
|
137
161
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: socotra-build
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.44
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Antenesse
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-07-
|
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Common functions for build
|
|
14
14
|
email: chris.antenesse@socotra.com
|
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
40
40
|
version: '0'
|
|
41
41
|
requirements: []
|
|
42
42
|
rubyforge_project:
|
|
43
|
-
rubygems_version: 2.
|
|
43
|
+
rubygems_version: 2.4.8
|
|
44
44
|
signing_key:
|
|
45
45
|
specification_version: 4
|
|
46
46
|
summary: Build library
|