Skip to content

Instantly share code, notes, and snippets.

@ctgswallow
Created February 13, 2013 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctgswallow/4948302 to your computer and use it in GitHub Desktop.
Save ctgswallow/4948302 to your computer and use it in GitHub Desktop.
confusing redis stuff
# Retrieve all nodes' local hostnames and set the master_ip
# based on a match to *this* node's local hostname.
#
# I don't know why this is even necessary.
redis_nodes = all_provider_local_hostnames(node[:redis][:service_name])
master_ip = ""
myhostname = node[:cloud][:local_hostname] rescue node[:fqdn]
found = 0
redis_sorted_nodes = redis_nodes.sort
redis_sorted_nodes.length.times do |j|
if found == 1 then
master_ip = redis_sorted_nodes[j]
break
end
if redis_sorted_nodes[j] == myhostname then
found = 1
end
end
if master_ip == "" then
master_ip = redis_sorted_nodes[0]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment