Navigation Menu

Skip to content

Commit

Permalink
Add utility method to do any operation which triggers restarting of t…
Browse files Browse the repository at this point in the history
…he service
  • Loading branch information
piroor committed Apr 21, 2015
1 parent 7df997e commit 7e18d1b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/droonga/serf.rb
Expand Up @@ -218,6 +218,19 @@ def cluster_id
catalog.cluster_id
end

CHECK_RESTARTED_INTERVAL = 3
CHECK_RESTARTED_TIMEOUT = 60 * 5

def do_and_wait_restart(&block)
start_time = Time.now
previous_internal_name = get_tag("internal-name")
yield # the given operation must restart the service.
while Time.now - start_time < CHECK_RESTARTED_TIMEOUT and
get_tag("internal-name") == previous_internal_name
sleep(CHECK_RESTARTED_INTERVAL)
end
end

private
def ensure_serf
@serf_command ||= find_system_serf
Expand Down

0 comments on commit 7e18d1b

Please sign in to comment.