Navigation Menu

Skip to content

Commit

Permalink
droonga-engine: ignore "serf leave" failure
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jan 5, 2015
1 parent f20597b commit fe14e5e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/droonga/command/droonga_engine.rb
Expand Up @@ -23,6 +23,7 @@
require "sigdump/setup"

require "droonga/engine/version"
require "droonga/loggable"
require "droonga/path"
require "droonga/address"
require "droonga/serf"
Expand Down Expand Up @@ -335,6 +336,8 @@ def bind_heartbeat_socket
end

class MainLoop
include Loggable

def initialize(configuration)
@configuration = configuration
@loop = Coolio::Loop.default
Expand Down Expand Up @@ -390,16 +393,14 @@ def trap_signals
def stop_gracefully
@command_runner.stop
@catalog_observer.stop
@serf.leave
@serf_agent.stop
stop_serf
@service_runner.stop_gracefully
end

def stop_immediately
@command_runner.stop
@catalog_observer.stop
@serf.leave
@serf_agent.stop
stop_serf
@service_runner.stop_immediately
end

Expand Down Expand Up @@ -433,6 +434,15 @@ def start_serf
@serf_agent = @serf.run_agent(@loop)
end

def stop_serf
begin
@serf.leave
rescue Droonga::Serf::Command::Failure
logger.error("Failed to leave from Serf cluster: #{$!.message}")
end
@serf_agent.stop
end

def run_catalog_observer
catalog_observer = FileObserver.new(@loop, Path.catalog)
catalog_observer.on_change = lambda do
Expand All @@ -451,6 +461,10 @@ def run_command_runner
command_runner.start
command_runner
end

def log_tag
"droonga-engine"
end
end

class ServiceRunner
Expand Down

0 comments on commit fe14e5e

Please sign in to comment.