refactor(deploy): use HAProxy admin socket instead of stats HTTP API

This commit is contained in:
NetworkCats
2026-03-20 07:01:09 +08:00
parent 258f68af5d
commit 1c8f274453
3 changed files with 9 additions and 9 deletions
+6 -8
View File
@@ -217,12 +217,11 @@
docker kill -s HUP rustyip-haproxy
changed_when: true
- name: Force new backend out of maintenance via stats admin
- name: Force new backend out of maintenance via admin socket
ansible.builtin.shell: |
sleep 1
docker exec rustyip-haproxy wget -qO- \
--post-data='s=app/{{ deploy_target }}&action=ready' \
"http://127.0.0.1:9000/stats" 2>/dev/null
docker exec rustyip-haproxy sh -c \
'echo "set server app/{{ deploy_target }} state ready" | socat stdio unix:/var/run/haproxy/admin.sock'
changed_when: true
- name: Wait for new backend to be UP in HAProxy
@@ -282,12 +281,11 @@
changed_when: true
failed_when: false
- name: Force original backend out of maintenance via stats admin
- name: Force original backend out of maintenance via admin socket
ansible.builtin.shell: |
sleep 1
docker exec rustyip-haproxy wget -qO- \
--post-data='s=app/{{ current_active }}&action=ready' \
"http://127.0.0.1:9000/stats" 2>/dev/null
docker exec rustyip-haproxy sh -c \
'echo "set server app/{{ current_active }} state ready" | socat stdio unix:/var/run/haproxy/admin.sock'
changed_when: true
failed_when: false
@@ -9,6 +9,7 @@ services:
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./haproxy/ipv4_domain.lst:/usr/local/etc/haproxy/ipv4_domain.lst:ro
- ./haproxy/certs:/etc/haproxy/certs:ro
- haproxy_run:/var/run/haproxy
{% if ipv4_domain %}
- ./haproxy/certs-ipv4:/etc/haproxy/certs-ipv4:ro
{% endif %}
@@ -64,6 +65,7 @@ services:
- internal
volumes:
haproxy_run:
db_data_blue:
db_data_green:
@@ -1,6 +1,7 @@
global
log stderr local0 err
maxconn 10000
stats socket /var/run/haproxy/admin.sock mode 660 level admin
# Performance tuning for high-throughput
tune.bufsize 16384
tune.maxrewrite 1024
@@ -137,7 +138,6 @@ frontend stats_internal
stats enable
stats uri /stats
stats refresh 2s
stats admin if TRUE
resolvers docker_dns
nameserver dns1 127.0.0.11:53