[Groonga-commit] droonga/droonga-engine at a13ecc7 [master] Output progress in the same line

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Nov 21 21:19:44 JST 2014


YUKI Hiroshi	2014-11-21 21:19:44 +0900 (Fri, 21 Nov 2014)

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

  Message:
    Output progress in the same line

  Modified files:
    bin/droonga-engine-absorb-data
    bin/droonga-engine-join

  Modified: bin/droonga-engine-absorb-data (+8 -1)
===================================================================
--- bin/droonga-engine-absorb-data    2014-11-21 21:08:35 +0900 (d53b13b)
+++ bin/droonga-engine-absorb-data    2014-11-21 21:19:44 +0900 (3ba7805)
@@ -113,6 +113,7 @@ if options.remote
                      "port"    => options.port,
                      "tag"     => options.tag,
                      "dataset" => options.dataset)
+  last_progress = ""
   while true
     sleep(3)
     response = run_remote_command(destination_node, "report_status",
@@ -124,8 +125,14 @@ if options.remote
     end
 
     progress = absorber.report_progress(start_time_in_seconds)
-    puts(progress) if progress
+    if progress
+      printf("%s", "#{" " * last_progress.size}\r")
+      printf("%s", "#{progress}\r")
+      last_progress = progress
+    end
   end
+  puts ""
+
   response = run_remote_command(source_node, "report_status",
                                 "node" => source_node,
                                 "key" => "last_processed_message_timestamp")

  Modified: bin/droonga-engine-join (+7 -1)
===================================================================
--- bin/droonga-engine-join    2014-11-21 21:08:35 +0900 (6b914be)
+++ bin/droonga-engine-join    2014-11-21 21:19:44 +0900 (af2756f)
@@ -86,6 +86,7 @@ run_remote_command(joining_node, "join",
 sleep(5) #TODO: wait for restarting of the joining node. this should be done more safely.
 
 unless options["no-copy"]
+  last_progress = ""
   while true
     sleep(3)
     response = run_remote_command(joining_node, "report_status",
@@ -97,8 +98,13 @@ unless options["no-copy"]
     end
 
     progress = absorber.report_progress(start_time_in_seconds)
-    puts(progress) if progress
+    if progress
+      printf("%s", "#{" " * last_progress.size}\r")
+      printf("%s", "#{progress}\r")
+      last_progress = progress
+    end
   end
+  puts ""
 end
 
 response = run_remote_command(source_node, "report_status",
-------------- next part --------------
HTML����������������������������...
Download 



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