enviroblyd 0.4 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/enviroblyd/command.rb +1 -0
- data/lib/enviroblyd/version.rb +1 -1
- data/lib/enviroblyd/web.rb +6 -10
- 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: 28e33b71b8d370a6ea6239748afe9e0bbb6023325cd3f46ae070e2e8433531f3
|
4
|
+
data.tar.gz: 3485336ad0bff70f3bb983d9487ad650c8b18f5afce4a45e2ec4a2ef167815f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c303fba4a8693104fe31b69fd6af04a8d4c1899a51c9c8f949bec21dd8f378fefcc9fb81161db793b4344f9eceffe3d160e0e0bb04709e8dcbc9c555ce7f163
|
7
|
+
data.tar.gz: dd2b1d9035182ec8a18ed9f3b2cff027afe017f7c37f3b2d31b142b1ae92a783461c716d7804d2daf4a109bad334eae3ce47d09f9dc0efdc0574ffce2583a707
|
data/lib/enviroblyd/command.rb
CHANGED
data/lib/enviroblyd/version.rb
CHANGED
data/lib/enviroblyd/web.rb
CHANGED
@@ -22,7 +22,7 @@ class Enviroblyd::Web
|
|
22
22
|
else
|
23
23
|
init_url = ENV.fetch "ENVIROBLYD_INIT_URL"
|
24
24
|
puts "Init URL: #{init_url}"
|
25
|
-
response = http(init_url, type: Net::HTTP::Put
|
25
|
+
response = http(init_url, type: Net::HTTP::Put)
|
26
26
|
puts "Init response code: #{response.code}"
|
27
27
|
|
28
28
|
if response.code.to_i == 200
|
@@ -32,7 +32,7 @@ class Enviroblyd::Web
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def http(url, type: Net::HTTP::Get, headers: {}, retry_interval:
|
35
|
+
def http(url, type: Net::HTTP::Get, params: nil, headers: {}, retry_interval: 3, retries: 10, backoff: :exponential, tries: 1)
|
36
36
|
if retries <= tries
|
37
37
|
$stderr.puts "Retried #{tries} times. Aborting."
|
38
38
|
exit 1
|
@@ -41,15 +41,12 @@ class Enviroblyd::Web
|
|
41
41
|
uri = URI(url)
|
42
42
|
http = Net::HTTP.new uri.host, uri.port
|
43
43
|
http.use_ssl = true if uri.scheme == "https"
|
44
|
-
http.open_timeout =
|
45
|
-
http.read_timeout =
|
44
|
+
http.open_timeout = 10
|
45
|
+
http.read_timeout = 10
|
46
46
|
|
47
47
|
request = type.new(uri, default_headers.merge(headers))
|
48
48
|
request.content_type = CONTENT_TYPE
|
49
|
-
|
50
|
-
unless params.nil?
|
51
|
-
request.body = JSON.dump params
|
52
|
-
end
|
49
|
+
request.body = JSON.dump(params) unless params.nil?
|
53
50
|
|
54
51
|
response =
|
55
52
|
begin
|
@@ -58,12 +55,11 @@ class Enviroblyd::Web
|
|
58
55
|
:retry
|
59
56
|
end
|
60
57
|
|
61
|
-
# https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-1xxx-errors/
|
62
58
|
if response == :retry || (500..599).include?(response.code.to_i)
|
63
59
|
sleep_time = (backoff == :exponential) ? (retry_interval * tries) : retry_interval
|
64
60
|
$stderr.puts "Retry #{uri} in #{sleep_time}s"
|
65
61
|
sleep sleep_time
|
66
|
-
http(url, type:, retry_interval:, retries:, backoff:, tries: (tries + 1))
|
62
|
+
http(url, type:, params:, retry_interval:, retries:, backoff:, tries: (tries + 1))
|
67
63
|
else
|
68
64
|
response
|
69
65
|
end
|