[Groonga-commit] droonga/droonga-engine at 5ce051e [master] droonga-engine: support reverting old service process on restart failure

Back to archive index

Kouhei Sutou null+****@clear*****
Wed May 28 12:11:54 JST 2014


Kouhei Sutou	2014-05-28 12:11:54 +0900 (Wed, 28 May 2014)

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

  Message:
    droonga-engine: support reverting old service process on restart failure
    
    For example, invalid catalog.json case.

  Modified files:
    lib/droonga/command/droonga_engine.rb

  Modified: lib/droonga/command/droonga_engine.rb (+16 -0)
===================================================================
--- lib/droonga/command/droonga_engine.rb    2014-05-28 12:09:29 +0900 (d21a9d4)
+++ lib/droonga/command/droonga_engine.rb    2014-05-28 12:11:54 +0900 (8c7108c)
@@ -281,8 +281,13 @@ module Droonga
           old_service_runner = @service_runner
           @service_runner = run_service
           @service_runner.on_ready = lambda do
+            @service_runner.on_failure = nil
             old_service_runner.stop_gracefully
           end
+          @service_runner.on_failure = lambda do
+            @service_runner.on_failure = nil
+            @service_runner = old_service_runner
+          end
         end
 
         def restart_immediately
@@ -321,12 +326,18 @@ module Droonga
           @raw_loop = raw_loop
           @configuration = configuration
           @success = false
+          @on_ready = nil
+          @on_failure = nil
         end
 
         def on_ready=(callback)
           @on_ready = callback
         end
 
+        def on_failure=(callback)
+          @on_failure = callback
+        end
+
         def run
           control_write_in, control_write_out = IO.pipe
           control_read_in, control_read_out = IO.pipe
@@ -377,11 +388,16 @@ module Droonga
           @on_ready.call if @on_ready
         end
 
+        def on_failure
+          @on_failure.call if @on_failure
+        end
+
         def on_finish
           _, status = Process.waitpid2(@pid)
           @success = status.success?
           @control_write_out.close
           @control_read_in.close
+          on_failure unless success?
         end
 
         def attach_control_write_out(control_write_out)
-------------- next part --------------
HTML����������������������������...
下载 



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