10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/stay_awake/strategies/httparty.rb', line 10
def self.buzz(url)
require 'timeout'
StayAwake.logger.info 'Starting buzzing using HTTParty.'
@thread = Thread.new do
loop do
begin
Timeout.timeout(30) do
uuid = SecureRandom.uuid
StayAwake.logger.debug "Starting HTTP Request (#{uuid})."
HTTParty.send(StayAwake.config.request_method, url)
StayAwake.logger.debug "HTTP Response arrived (#{uuid})."
end
rescue Timeout::Error
StayAwake.logger.error "HTTP Timeout Error after 30 seconds (#{uuid})."
rescue StandardError => e
StayAwake.logger.error e.message
end
sleep StayAwake.config.interval
end
end
end
|