Skip to content

Commit

Permalink
refine timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Nov 22, 2024
1 parent af2f55b commit d6cd6f4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src-colladmin/actions/tag_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def initialize(config, inst)
@subservice = tag.value if tag.key == 'Subservice'
end
@httpclient = HTTPClient.new
@httpclient.receive_timeout = 1000
@httpclient.receive_timeout = 10
@httpclient.connect_timeout = 5
@httpclient.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
@buildtag = ''
@starttime = ''
@servicestate = ''
Expand Down Expand Up @@ -138,6 +140,7 @@ def urldata(url)

resp.body
rescue StandardError => e
puts "GET #{url}: #{e}"
e.to_s
end
end
Expand Down Expand Up @@ -254,6 +257,11 @@ def initialize(config, action, path, myparams)
@label = myparams.fetch('label', '')
@list_servers = @name.empty?

@httpclient = HTTPClient.new
@httpclient.receive_timeout = 20
@httpclient.connect_timeout = 5
@httpclient.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE

data = @ec2.describe_instances({
filters: [
{
Expand Down Expand Up @@ -304,14 +312,20 @@ def endpoint_call
url = ec2.urls.fetch(@label, '')
return 'No Url found' if url.empty?

cli = HTTPClient.new
cli.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
if @label == 'stop' || @label == 'start'
puts "POST #{url}"
resp = cli.post(url)
begin
resp = @httpclient.post(url)
rescue StandardError => e
puts "POST #{url}: #{e}"
return e.to_s
end
else
puts "GET #{url}"
resp = cli.get(url, follow_redirect: true)
begin
resp = @httpclient.get(url, follow_redirect: true)
rescue StandardError => e
puts "GET #{url}: #{e}"
return e.to_s
end
end
ret = resp.body
return ret if @label == 'build-info'
Expand Down

0 comments on commit d6cd6f4

Please sign in to comment.