Skip to content

Commit

Permalink
Use ruby DNS resolver and set DNS resolution timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
johanek committed Jan 14, 2019
1 parent b025c62 commit 9c1dce1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/check-http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
require 'net/http'
require 'net/https'
require 'digest'
require 'resolv-replace'

#
# Check HTTP
Expand Down Expand Up @@ -262,6 +263,11 @@ def run
config[:port] ||= config[:ssl] ? 443 : 80
end

# Use Ruby DNS Resolver and set DNS resolution timeout to 800ms
dns_resolver = Resolv::DNS.new
dns_resolver.timeouts = 0.8
Resolv::DefaultResolver.replace_resolvers([dns_resolver])

begin
Timeout.timeout(config[:timeout]) do
acquire_resource
Expand Down

0 comments on commit 9c1dce1

Please sign in to comment.