Skip to content

Commit

Permalink
Fix bad threading code
Browse files Browse the repository at this point in the history
  • Loading branch information
edhgoose committed May 4, 2016
1 parent cdfad6f commit 1d671a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/capify-ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def deregister_instance_from_named_elbs_by_dns(server_dns, load_balancer_names)
threads = []

for load_balancer_name in load_balancer_names do
threads << Thread.new({
load_balancer = get_load_balancer_by_name(load_balancer_name)
threads << Thread.new(load_balancer_name) do |lb|
load_balancer = get_load_balancer_by_name(lb)

if load_balancer
puts "[Capify-EC2] Removing instance from named ELB '#{load_balancer.id}'..."
Expand All @@ -323,7 +323,7 @@ def deregister_instance_from_named_elbs_by_dns(server_dns, load_balancer_names)

lbs << load_balancer
end
})
end
end

for t in threads do
Expand Down
12 changes: 6 additions & 6 deletions lib/capify-ec2/capistrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,17 @@ def capify_ec2
threads = []

for load_balancer_to_reregister in load_balancers_to_reregister do
threads << Thread.new({
puts "[Capify-EC2] Starting registration of ELB '#{load_balancer_to_reregister.id}'"
threads << Thread.new(load_balancer_to_reregister) do |lb|
puts "[Capify-EC2] Starting registration of ELB '#{lb.id}'"

reregistered = capify_ec2.reregister_instance_with_elb_by_dns(server_dns, load_balancer_to_reregister, 60)
reregistered = capify_ec2.reregister_instance_with_elb_by_dns(server_dns, lb, 60)
if reregistered
puts "[Capify-EC2] Instance registration with ELB '#{load_balancer_to_reregister.id}' successful.".green.bold
puts "[Capify-EC2] Instance registration with ELB '#{lb.id}' successful.".green.bold
else
puts "[Capify-EC2] Instance registration with ELB '#{load_balancer_to_reregister.id}' failed!".red.bold
puts "[Capify-EC2] Instance registration with ELB '#{lb.id}' failed!".red.bold
raise CapifyEC2RollingDeployError.new("ELB registration timeout exceeded", server_dns)
end
})
end
end

for t in threads do
Expand Down

0 comments on commit 1d671a7

Please sign in to comment.