Update timeout for uptime monitors

This commit is contained in:
Omar Roth 2019-09-26 10:25:05 -04:00
parent 51c67b3da6
commit 5a7ba726c9
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2
1 changed files with 6 additions and 4 deletions

View File

@ -34,7 +34,10 @@ spawn do
page = 1
loop do
begin
response = JSON.parse(HTTP::Client.get(URI.parse("https://uptime.invidio.us/api/getMonitorList/89VnzSKAn?page=#{page}")).body)
client = HTTP::Client.new(URI.parse("https://uptime.invidio.us"))
client.connect_timeout = 10.seconds
client.read_timeout = 10.seconds
response = JSON.parse(client.get("/api/getMonitorList/89VnzSKAn?page=#{page}").body)
monitors += response["psp"]["monitors"].as_a
page += 1
@ -46,7 +49,6 @@ spawn do
error_message = response.try &.["errorStats"]?
error_message ||= ex.message
puts "Exception pulling monitors: #{error_message}"
next
end
end
@ -75,11 +77,11 @@ spawn do
end
end
monitor = monitors.select { |monitor| monitor["name"].try &.as_s == host }[0]?
monitor = monitors.try &.select { |monitor| monitor["name"].try &.as_s == host }[0]?
INSTANCES[host] = {flag: flag, region: region, stats: stats, type: type, uri: uri.to_s, monitor: monitor}
end
sleep 1.minute
sleep 5.minutes
Fiber.yield
end
end