9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/oggle.rb', line 9
def self.poll(servers)
servers.each do|server|
http = EM::HttpRequest.new(server[1]['url']).get :redirects => 5
http.errback do
EM.next_tick { settings.sockets.each{|s| s.send(create_message(server, 'error').to_json)}}
server[1]['status'] = 'error'
end
http.callback do
status = 'error'
status = 'ok' if http.response.to_s.include?(server[1]['check'])
EM.next_tick { settings.sockets.each{|s| s.send(create_message(server, status).to_json)}}
server[1]['status'] = status
end
end
end
|