Skip to content

Commit

Permalink
Restart haproxy if backend 'weights' setting is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiffany Low committed Mar 28, 2016
1 parent c3bcd29 commit ff7da3b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/synapse/haproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ def generate_backend_stanza(watcher, config)
log.info "synapse: restart required because haproxy_server_options changed for #{backend_name}"
@restart_required = true
end
if (old_backend.fetch('weight', "") !=
backend.fetch('weight', ""))
log.info "synapse: restart required because weight changed for #{backend_name}"
@restart_required = true
end
end
backends[backend_name] = backend.merge('enabled' => true)
end
Expand Down Expand Up @@ -743,10 +748,13 @@ def generate_backend_stanza(watcher, config)
b = "#{b} cookie #{backend_name}" unless config.include?('mode tcp')
b = "#{b} #{watcher.haproxy['server_options']}" if watcher.haproxy['server_options']
if backend.has_key?('weight')
# Check if server_options already contains weight, is so log a warning
if watcher.haproxy['server_options'].include? 'weight'
# Check if server_options/haproxy_server_options already contains weight, if so log a warning
if watcher.haproxy.fetch('server_options', '').include? 'weight'
log.warn "synapse: weight is defined by server_options and by nerve"
end
if backend['haproxy_server_options'] and backend['haproxy_server_options'].include? 'weight'
log.warn "synapse: weight is defined by haproxy_server_options and by nerve"
end
weight = backend['weight'].to_i
b = "#{b} weight #{weight}"
end
Expand Down

0 comments on commit ff7da3b

Please sign in to comment.