lib/dumper/agent.rb in dumper-0.0.6 vs lib/dumper/agent.rb in dumper-0.0.7

- old
+ new

@@ -43,13 +43,15 @@ begin sec *= 2 log "sleeping #{sec} seconds for agent/register.", :debug sleep sec json = send_request(api: 'agent/register', json: MultiJson.encode(register_hash)) - end until json[:status] == 'ok' + end until json[:status] - log 'agent started.' + return log("agent stopped: #{json.to_s}") if json[:status] == 'error' + @token = json[:token] + log "agent started as #{@token ? 'primary' : 'secondary'}" sleep 1.hour unless @token loop do json = send_request(api: 'agent/poll', params: { token: @token })