Skip to content

Instantly share code, notes, and snippets.

@robins35
Created July 9, 2019 16:27
Show Gist options
  • Save robins35/e1b9e0c5beb2e4d8f9ca6828981c9cb7 to your computer and use it in GitHub Desktop.
Save robins35/e1b9e0c5beb2e4d8f9ca6828981c9cb7 to your computer and use it in GitHub Desktop.
#!/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