-
-
Save brianbier/1697e7fca4b1535cb89b6831a2baa950 to your computer and use it in GitHub Desktop.
A script to check GitHub's status.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/http' | |
status = nil | |
until status == 'good' | |
url = URI('https://status.github.com/api/status.json') | |
response = Net::HTTP.get(url) | |
body = JSON.parse(response) | |
p body | |
status = body['status'] | |
sleep 5 | |
end | |
puts 'GitHub has recovered!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'net/http' | |
# initialize the status with some harmless value. this lets us check the value the first time without getting an error. | |
status = nil | |
# until we modify the `status` variable to equal 'good' (the options are 'good', 'minor' or 'major') | |
until status == 'good' | |
# the Net::HTTP get method demands an URI object, that gets initialized by the full URL string | |
url = URI('https://status.github.com/api/status.json') | |
# this actually goes and gets the information from the github servers. | |
response = Net::HTTP.get(url) | |
# the response is in a format called JSON (or JavaScript Object Notation) - this parses it into a Ruby Hash | |
body = JSON.parse(response) | |
# print out the Ruby hash containing the status information | |
p body | |
# set the `status` variable to equal the status information from the GitHub servers | |
status = body['status'] | |
# wait for 5 seconds so that we don't just keep spamming the GitHub servers | |
sleep 5 | |
end | |
# this line will not be executed until the loop stops. the loop will only stop until the status == 'good' | |
puts 'GitHub has recovered!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment