summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2014-01-03 11:57:31 +0100
committerAzul <azul@riseup.net>2014-01-03 14:50:04 +0100
commit10807e06165bb78261b9da0f5e44666c56c1f8f2 (patch)
treec35fdee5ecdee69fd3084a1d09f20ae819c2bf16
parent32409f06920cfa2eb9e23deb74c3e09db677fe77 (diff)
better debug loggin, sleep before retrying
-rwxr-xr-xbin/tapicero4
-rw-r--r--lib/tapicero/user_database.rb13
2 files changed, 9 insertions, 8 deletions
diff --git a/bin/tapicero b/bin/tapicero
index 1c23947..b2eebed 100755
--- a/bin/tapicero
+++ b/bin/tapicero
@@ -69,7 +69,7 @@ end
begin
Daemons.run("#{BASE_DIR}/lib/tapicero_daemon.rb", options)
rescue Exception => exc
- Tapicero.logger.error "TAPICERO DYING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+ Tapicero.logger.error "Uncaught exception. Daemon will die."
Tapicero.logger.error exc.to_s
- Tapicero.logger.error exc.backtrace
+ Tapicero.logger.error exc.backtrace.join("\n")
end
diff --git a/lib/tapicero/user_database.rb b/lib/tapicero/user_database.rb
index a905756..c499850 100644
--- a/lib/tapicero/user_database.rb
+++ b/lib/tapicero/user_database.rb
@@ -67,20 +67,21 @@ module Tapicero
def retry_request_once(action)
second_try ||= false
yield
- rescue RestClient::Exception => e
+ rescue RestClient::Exception => exc
if second_try
- log_error action + " failed twice due to:", e
+ log_error action + " failed twice due to:", exc
else
- log_error action + " failed due to:", e
+ log_error action + " failed due to:", exc
+ sleep 5
second_try = true
retry
end
end
- def log_error(message, e)
+ def log_error(message, exc)
Tapicero.logger.warn message if message
- Tapicero.logger.warn e.to_s
- Tapicero.logger.debug e.backtrace
+ Tapicero.logger.warn exc.to_s
+ Tapicero.logger.debug exc.backtrace.join("\n")
end
def secured?