socotra-build 0.3.29 → 0.3.30
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 +22 -21
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 927edabbae63ccee8968062ea62b9e393a6ffeb6
|
|
4
|
+
data.tar.gz: 36353731e2d8bcc9f9f17bd9fd8b3f4b71b0e0c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f3a4f410376ef13c03e5dc732677cac0260cb7d3fa4094e4797a728816897aafdee297f5cec0ce3835a7fea3752460aa8339657e91243a365bceba5ede0d965
|
|
7
|
+
data.tar.gz: 30d79b0cfc3d66792717ac9b82aa22c20d1d48de93f7416a40e8eec0e020cfdbe0f958710c64980d26391655fbd12944bce07829d103c13cd49ac597fd69d648
|
data/lib/socotra-build.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require 'open3'
|
|
2
2
|
require 'set'
|
|
3
|
+
require 'timeout'
|
|
3
4
|
require_relative 's3_uploader'
|
|
4
5
|
|
|
5
|
-
def self.safe_retry(cmd, description, error_message="command failed", raise_on_fail=true, log_level="ERROR", log=true, tries=3)
|
|
6
|
+
def self.safe_retry(cmd, description, error_message="command failed", raise_on_fail=true, log_level="ERROR", log=true, tries=3, timeout=0)
|
|
6
7
|
begin
|
|
7
|
-
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)
|
|
8
|
+
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)
|
|
8
9
|
rescue
|
|
9
10
|
if (tries -= 1) > 0
|
|
10
11
|
sleep 5
|
|
@@ -49,11 +50,7 @@ def self.get_sanitized_cmd(cmd)
|
|
|
49
50
|
cmd = cmd.join(' ')
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, log_level="ERROR", log=true, print_command=true, retry_exec=false)
|
|
53
|
-
Signal.trap("TERM") do
|
|
54
|
-
puts "SIGTERM caught, quitting..."
|
|
55
|
-
end
|
|
56
|
-
|
|
53
|
+
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)
|
|
57
54
|
start = Time.now.to_i
|
|
58
55
|
|
|
59
56
|
cmd_sanitized = get_sanitized_cmd(cmd)
|
|
@@ -62,31 +59,35 @@ def self.system_safe(cmd, cmd_description, error_message, raise_on_fail=true, lo
|
|
|
62
59
|
else
|
|
63
60
|
puts "Not logging command"
|
|
64
61
|
end
|
|
65
|
-
|
|
66
|
-
stdout, stderr, status = Open3.capture3(cmd)
|
|
67
|
-
elapsed = Time.now.to_i - start
|
|
68
62
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
pid = spawn(cmd, :out=>"logs/#{cmd_description}_out.log", :err=>"logs/#{cmd_description}_err.log")
|
|
64
|
+
begin
|
|
65
|
+
Timeout::timeout(timeout) do
|
|
66
|
+
Process.wait(pid)
|
|
67
|
+
success = true
|
|
68
|
+
end
|
|
69
|
+
rescue Timeout::Error
|
|
70
|
+
Process.kill('INT', pid)
|
|
71
|
+
success = false
|
|
75
72
|
end
|
|
76
73
|
|
|
74
|
+
puts "\tLogs available here: #{cmd_description}_err.log and #{cmd_description}_out.log\n\n"
|
|
75
|
+
|
|
76
|
+
elapsed = Time.now.to_i - start
|
|
77
|
+
|
|
77
78
|
puts "\t#{cmd_description} took #{elapsed} seconds"
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
if not success and raise_on_fail
|
|
80
81
|
if retry_exec
|
|
81
82
|
log_level = "WARNING"
|
|
82
83
|
end
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if log
|
|
85
|
+
puts "#{log_level}: see logs/#{cmd_description}_out.log and #{cmd_description}_err.log for details"
|
|
86
|
+
end
|
|
86
87
|
raise "#{log_level}: #{error_message}"
|
|
87
88
|
end
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
return [success, stdout]
|
|
90
91
|
end
|
|
91
92
|
|
|
92
93
|
def self.system_unsafe(cmd)
|
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.30
|
|
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-06
|
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Common functions for build
|
|
14
14
|
email: chris.antenesse@socotra.com
|