Skip to content

Commit

Permalink
add domain checking method
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwilkin committed Nov 14, 2010
1 parent 9654543 commit ef9d754
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions minder.rb
Expand Up @@ -4,6 +4,8 @@
require 'yaml'
require 'xmpp4r-simple'

TIMEOUT = 10 # max time to attempt to access each domain

# globals
$user = nil
$pass = nil
Expand All @@ -27,6 +29,22 @@ def message(msg)
sleep 1
end

def can_read_domain?(domain)
print "Checking #{domain}: "
url = "http://#{domain}/"
begin
Timeout::timeout(TIMEOUT) do
open(url, 'Cache-Control' => 'no-cache').read
end
rescue Timeout::Error
puts 'down!'
false
else
puts 'ok'
true
end
end

def main
load_config
end
Expand Down

0 comments on commit ef9d754

Please sign in to comment.