Kouhei Sutou
null+****@clear*****
Fri May 23 16:25:02 JST 2014
Kouhei Sutou 2014-05-23 16:25:02 +0900 (Fri, 23 May 2014) New Revision: f53383f26c6c462e96a8a1527f5f3f70f7d98c5f https://github.com/droonga/droonga-engine/commit/f53383f26c6c462e96a8a1527f5f3f70f7d98c5f Message: Shutdown Serf before stopping engine If engine is stopped before Serf, some requests are sent to stopped engines. Modified files: lib/droonga/command/droonga_engine.rb lib/droonga/serf.rb Modified: lib/droonga/command/droonga_engine.rb (+7 -6) =================================================================== --- lib/droonga/command/droonga_engine.rb 2014-05-22 16:19:28 +0900 (61c6150) +++ lib/droonga/command/droonga_engine.rb 2014-05-23 16:25:02 +0900 (d2f313c) @@ -193,15 +193,19 @@ module Droonga def run_main_loop raw_loop = Coolio::Loop.default + serf = nil service_runner = nil trap(:INT) do + serf.shutdown if serf service_runner.stop_immedieate if service_runner raw_loop.stop end trap(Signals::GRACEFUL_STOP) do + serf.shutdown if serf service_runner.stop_graceful if service_runner end trap(Signals::IMMEDIATE_STOP) do + serf.shutdown if serf service_runner.stop_immediate if service_runner raw_loop.stop end @@ -219,12 +223,9 @@ module Droonga end serf = run_serf(raw_loop) - begin - service_runner = run_service(raw_loop) - raw_loop.run - ensure - serf.shutdown - end + service_runner = run_service(raw_loop) + raw_loop.run + serf.shutdown if serf.running? service_runner.success? end Modified: lib/droonga/serf.rb (+6 -0) =================================================================== --- lib/droonga/serf.rb 2014-05-22 16:19:28 +0900 (5512377) +++ lib/droonga/serf.rb 2014-05-23 16:25:02 +0900 (35c9b76) @@ -31,6 +31,7 @@ module Droonga def initialize(loop, name) @loop = loop @name = name + @serf_pid = nil end def start @@ -50,10 +51,15 @@ module Droonga logger.trace("start: done") end + def running? + not @serf_pid.nil? + end + def shutdown logger.trace("shutdown: start") Process.waitpid(run("leave")) Process.waitpid(@serf_pid) + @serf_pid = nil logger.trace("shutdown: done") end -------------- next part -------------- HTML����������������������������... ダウンロード