[Groonga-commit] droonga/droonga-engine at bf24b21 [master] Retry download of serf executable automatically

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Sep 29 13:52:29 JST 2014


YUKI Hiroshi	2014-09-29 13:52:29 +0900 (Mon, 29 Sep 2014)

  New Revision: bf24b2149c4eedce39844a9ccacf3fc17e79148d
  https://github.com/droonga/droonga-engine/commit/bf24b2149c4eedce39844a9ccacf3fc17e79148d

  Message:
    Retry download of serf executable automatically

  Modified files:
    lib/droonga/serf_downloader.rb

  Modified: lib/droonga/serf_downloader.rb (+16 -0)
===================================================================
--- lib/droonga/serf_downloader.rb    2014-09-29 12:32:45 +0900 (d0e488f)
+++ lib/droonga/serf_downloader.rb    2014-09-29 13:52:29 +0900 (347010b)
@@ -27,8 +27,15 @@ module Droonga
   class SerfDownloader
     include Loggable
 
+    class DownloadFailed < StandardError
+    end
+
+    MAX_RETRY_COUNT = 5
+    RETRY_INTERVAL  = 10
+
     def initialize(output_path)
       @output_path = output_path
+      @retry_count = 0
     end
 
     def download
@@ -49,6 +56,15 @@ module Droonga
         FileUtils.mv("#{dir}/serf", absolete_output_path.to_s)
         FileUtils.chmod(0755, absolete_output_path.to_s)
       end
+    rescue Archive::Zip::UnzipError => archive_error
+      logger.warn("Downloaded zip file is broken.")
+      if @retry_count < MAX_RETRY_COUNT
+        @retry_count += 1
+        sleep(RETRY_INTERVAL)
+        download
+      else
+        raise DownloadFailed.new("Couldn't download serf executable. Try it later.")
+      end
     end
 
     private
-------------- next part --------------
HTML����������������������������...
下載 



More information about the Groonga-commit mailing list
Back to archive index