Sha256: 966353491a6928bb011bbd8047043d42af2998e9db6c879b4334f6bb48905f05
Contents?: true
Size: 766 Bytes
Versions: 7
Compression:
Stored size: 766 Bytes
Contents
#!/usr/bin/env ruby require 'open-uri' require 'openssl' # Interval between retries (in seconds) INTERVAL_LENGTH = 5.0 # Maximum amount of time to keep retrying (in seconds) MAX_TIME_TO_RETRY = 300.0 if ARGV.length != 1 puts 'USAGE: wait_for_url <url>' exit end url = ARGV[0] retries = (MAX_TIME_TO_RETRY / INTERVAL_LENGTH).ceil begin puts "Fetching #{url}" open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, redirect: false) rescue OpenURI::HTTPError => error response = error.io puts "Response status code: #{response.status[0]}" unless (retries -= 1).zero? || response.status[0] != '500' sleep(INTERVAL_LENGTH) retry end rescue OpenURI::HTTPRedirect => error puts "Redirect to: #{error.uri}" end
Version data entries
7 entries across 7 versions & 1 rubygems