Skip to content

Commit 4714fa4

Browse files
committed
Add healthcheck for haproxy
1 parent 2ba480e commit 4714fa4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

services/rabbit/docker-compose.yml.j2

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ services:
2020
reservations:
2121
cpus: "0.1"
2222
memory: "128M"
23-
# healthcheck: https://github.com/haproxy/haproxy/issues/3091
23+
healthcheck: # https://stackoverflow.com/a/76513320/12124525
24+
test: bash -c 'echo "" > /dev/tcp/127.0.0.1/32087 || exit 1'
25+
start_period: 5s
26+
timeout: 2s
27+
retries: 2
28+
interval: 10s
29+
2430
networks:
2531
- rabbit
2632
configs:

services/rabbit/haproxy.cfg.j2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ frontend rabbit_dashboard
3838
bind *:{{ RABBIT_MANAGEMENT_PORT }}
3939
default_backend rabbit_dashboard_backends
4040

41+
frontend health
42+
mode http
43+
bind 127.0.0.1:32087
44+
http-request return status 200 if { src 127.0.0.0/8 }
45+
4146
backend rabbit_backends
4247
# side effect of roundrobin is connection should be evenly distributed
4348
# thus rabbit queue leader replica shall be also evenly distributed

services/rabbit/template.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ RABBIT_LB_REPLICAS=${RABBIT_LB_REPLICAS}
1313
RABBIT_NETWORK=${RABBIT_NETWORK}
1414

1515
PUBLIC_NETWORK=${PUBLIC_NETWORK}
16-
MONITORING_DOMAIN=${MONITORING_DOMAIN}

0 commit comments

Comments
 (0)