Navigation Menu

Skip to content

Commit

Permalink
Initialize tags without its own on_ready callback
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 21, 2015
1 parent d9e54d7 commit 888e478
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/droonga/command/droonga_engine.rb
Expand Up @@ -413,6 +413,7 @@ def run_internal
start_serf
@serf_agent.on_ready = lambda do
logger.trace("run_internal: serf agent is ready")
@serf.initialize_tags
@serf.update_cluster_state
@service_runner = run_service
setup_initial_on_ready
Expand Down
15 changes: 8 additions & 7 deletions lib/droonga/serf.rb
Expand Up @@ -65,18 +65,19 @@ def run_agent(loop)
"-event-handler", "droonga-engine-serf-event-handler",
"-tags-file", tags_file.to_s,
*retry_joins)
agent.on_ready = lambda do
set_tag("type", "engine")
set_tag("cluster_id", cluster_id)
current_role = role
set_tag("role", current_role)
NodeRole.my_role = current_role
end
agent.start
logger.trace("run_agent: done")
agent
end

def initialize_tags
set_tag("type", "engine")
set_tag("cluster_id", cluster_id)
current_role = role
set_tag("role", current_role)
NodeRole.my_role = current_role
end

def leave
run_command("leave")
end
Expand Down
1 change: 1 addition & 0 deletions lib/droonga/serf/agent.rb
Expand Up @@ -196,6 +196,7 @@ def start_ready_check
checker = Coolio::TCPSocket.connect(@host, @bind_port)

on_connect = lambda do
@serf.initialize_tags
on_ready
checker.close
# logger.trace("start_ready_check: checker watcher detached",
Expand Down

0 comments on commit 888e478

Please sign in to comment.