File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 179179 docker kill -s HUP rustyip-haproxy
180180 changed_when : true
181181
182- - name : Wait for HAProxy to settle
183- ansible.builtin.pause :
184- seconds : 5
182+ - name : Wait for new backend to be UP in HAProxy
183+ ansible.builtin.shell : |
184+ for i in $(seq 1 30); do
185+ csv=$(docker exec rustyip-haproxy wget -qO- \
186+ "http://127.0.0.1:9000/stats;csv;norefresh" 2>/dev/null)
187+ status=$(echo "$csv" | awk -F, '$1 == "app" && $2 == "{{ deploy_target }}" {print $18}')
188+ if [ "$status" = "UP" ]; then
189+ echo "backend {{ deploy_target }} is UP in HAProxy"
190+ exit 0
191+ fi
192+ sleep 2
193+ done
194+ echo "timeout waiting for backend {{ deploy_target }} to become UP"
195+ exit 1
196+ changed_when : false
185197
186198 - name : Stop old active container
187199 ansible.builtin.shell : |
Original file line number Diff line number Diff line change @@ -65,13 +65,21 @@ frontend https_in
6565backend global_rate_tracking
6666 stick-table type string len 6 size 1 expire 10m store http_req_rate(1s)
6767
68+ frontend stats_internal
69+ bind 127.0.0.1:9000
70+ mode http
71+ stats enable
72+ stats uri /stats
73+ stats refresh 2s
74+
6875resolvers docker_dns
6976 nameserver dns1 127.0.0.11:53
7077 resolve_retries 3
7178 timeout resolve 1s
7279 timeout retry 1s
7380 hold valid 10s
74- hold nx 5s
81+ hold nx 30s
82+ hold obsolete 30s
7583
7684backend app
7785 balance roundrobin
You can’t perform that action at this time.
0 commit comments