10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/deploy_agent/agent.rb', line 10
def run
nio_selector = NIO::Selector.new
timers = Timers::Group.new
target = ENV['DEPLOY_AGENT_PROXY_IP'] || 'agent.deployhq.com'
server_connection = ServerConnection.new(self, target, nio_selector, !ENV['DEPLOY_AGENT_NOVERIFY'])
timers.every(60) { server_connection.keepalive }
loop do
wait_interval = timers.wait_interval
wait_interval = 0 if wait_interval < 0
nio_selector.select(wait_interval) do |monitor|
monitor.value.rx_data if monitor.readable?
monitor.value.tx_data if monitor.writeable?
end
timers.fire
end
rescue ServerConnection::ServerDisconnected
retry
end
|