@@ -716,6 +716,11 @@ def generate_backend_stanza(watcher, config)
716
716
log . info "synapse: restart required because haproxy_server_options changed for #{ backend_name } "
717
717
@restart_required = true
718
718
end
719
+ if ( old_backend . fetch ( 'weight' , "" ) !=
720
+ backend . fetch ( 'weight' , "" ) )
721
+ log . info "synapse: restart required because weight changed for #{ backend_name } "
722
+ @restart_required = true
723
+ end
719
724
end
720
725
backends [ backend_name ] = backend . merge ( 'enabled' => true )
721
726
end
@@ -743,9 +748,12 @@ def generate_backend_stanza(watcher, config)
743
748
b = "#{ b } cookie #{ backend_name } " unless config . include? ( 'mode tcp' )
744
749
b = "#{ b } #{ watcher . haproxy [ 'server_options' ] } " if watcher . haproxy [ 'server_options' ]
745
750
if backend . has_key? ( 'weight' )
746
- # Check if server_options already contains weight, is so log a warning
747
- if watcher . haproxy [ 'server_options' ] . include? 'weight'
748
- log . warn "synapse: weight is defined by server_options and by nerve"
751
+ # Check if server_options/haproxy_server_options already contains weight, if so log a warning
752
+ if watcher . haproxy . fetch ( 'server_options' , '' ) . include? 'weight'
753
+ log . warn "synapse: weight is defined in both server_options and nerve. nerve weight takes precedence"
754
+ end
755
+ if backend [ 'haproxy_server_options' ] and backend [ 'haproxy_server_options' ] . include? 'weight'
756
+ log . warn "synapse: weight is defined in both haproxy_server_options and nerve. nerve weight takes precedence"
749
757
end
750
758
weight = backend [ 'weight' ] . to_i
751
759
b = "#{ b } weight #{ weight } "
0 commit comments