socotra-build 0.3.45 → 0.3.46
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 +19 -16
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e173cbb231f00b97623514d1ee2548899dd87d28
|
|
4
|
+
data.tar.gz: 99f0bbffceb76700d6fe3c2444d150dcce0c50a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c61977c0c970b25feafd15decd39a1dd784159a8fedfdaef789157238a7440bf1e1b587964745316db2c1278f0307084ecda2ecbfa98145f245763582f6632e
|
|
7
|
+
data.tar.gz: a309e16c835d59d0dc8bab260f02ca4f6d316e60965650313eef789393a845a447d68ad95c9bd7869b8f96cd8fefaf0a3f95d2e40b8d4c458c38d78f954e46c4
|
data/lib/socotra-build.rb
CHANGED
|
@@ -4,9 +4,9 @@ require 'timeout'
|
|
|
4
4
|
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
|
+
retry_count ||= 0
|
|
7
8
|
begin
|
|
8
|
-
retry_count
|
|
9
|
-
if tries == (retry_count)
|
|
9
|
+
if retry_count == (tries - 1)
|
|
10
10
|
last_try = true
|
|
11
11
|
else
|
|
12
12
|
last_try = false
|
|
@@ -15,7 +15,7 @@ def self.safe_retry(cmd, description, error_message="command failed", raise_on_f
|
|
|
15
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
16
|
rescue
|
|
17
17
|
sleep 5
|
|
18
|
-
retry if (retry_count += 1) < (tries
|
|
18
|
+
retry if (retry_count += 1) < (tries)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
if last_try and raise_on_fail
|
|
@@ -94,17 +94,21 @@ def self.execute_cmd(cmd, timeout, log_out, log_err)
|
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
-
def self.
|
|
98
|
-
|
|
97
|
+
def self.log(level, message)
|
|
99
98
|
date = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
99
|
+
puts "#{date} #{level}: #{message}"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_level, error_message, last_try)
|
|
103
|
+
|
|
100
104
|
if log
|
|
101
|
-
|
|
105
|
+
log("INFO", "Logs available here: #{log_err} and #{log_out}" )
|
|
102
106
|
else
|
|
103
|
-
|
|
107
|
+
log("INFO", "INFO: Logs unavailable due to user settings")
|
|
104
108
|
end
|
|
105
109
|
|
|
106
110
|
if not (success or retry_exec)
|
|
107
|
-
|
|
111
|
+
log(log_level, error_message)
|
|
108
112
|
raise
|
|
109
113
|
end
|
|
110
114
|
|
|
@@ -116,9 +120,10 @@ def self.logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_l
|
|
|
116
120
|
end
|
|
117
121
|
|
|
118
122
|
if log
|
|
119
|
-
|
|
123
|
+
log(log_level, "see #{log_out} and #{log_err} for details")
|
|
120
124
|
end
|
|
121
|
-
|
|
125
|
+
|
|
126
|
+
log(log_level, error_message)
|
|
122
127
|
|
|
123
128
|
if not last_try
|
|
124
129
|
raise
|
|
@@ -129,12 +134,11 @@ end
|
|
|
129
134
|
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)
|
|
130
135
|
start = Time.now.to_i
|
|
131
136
|
|
|
132
|
-
date = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
|
133
137
|
cmd_sanitized = get_sanitized_cmd(cmd)
|
|
134
138
|
if print_command
|
|
135
|
-
|
|
139
|
+
log("INFO", "Executing command: #{cmd_sanitized}")
|
|
136
140
|
else
|
|
137
|
-
|
|
141
|
+
log("INFO", "Not logging command")
|
|
138
142
|
end
|
|
139
143
|
|
|
140
144
|
if log
|
|
@@ -149,13 +153,12 @@ def self.system_safe(cmd=cmd, cmd_description=cmd_description, error_message=err
|
|
|
149
153
|
|
|
150
154
|
elapsed = Time.now.to_i - start
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
puts "#{date} INFO: #{cmd_description} took #{elapsed} seconds"
|
|
156
|
+
log("INFO", "#{cmd_description} took #{elapsed} seconds")
|
|
154
157
|
|
|
155
158
|
file = File.open(log_out, "rb")
|
|
156
159
|
out = file.read
|
|
157
160
|
|
|
158
|
-
logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_level, error_message)
|
|
161
|
+
logger(log, success, retry_exec, raise_on_fail, log_out, log_err, log_level, error_message, last_try)
|
|
159
162
|
|
|
160
163
|
return success
|
|
161
164
|
end
|