Created
July 9, 2019 16:27
-
-
Save robins35/e1b9e0c5beb2e4d8f9ca6828981c9cb7 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require "net/https" | |
require "uri" | |
puts "STARTING" | |
uri = URI.parse("https://mysite") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
begin | |
retries ||= 0 | |
request = Net::HTTP::Get.new(uri.request_uri) | |
res = http.request(request) | |
raise "Non-200 status code" unless res.code == "200" | |
rescue | |
sleep 10 | |
retries += 1 | |
retry if retries < 3 | |
puts "Restarting server" | |
#`cp-reboot` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment