Skip to content

Commit 34b9d1e

Browse files
henrylove0claude
andauthored
fix(erp): pgrep-free healthchecks + nginx upstream re-resolution (c8fb434f, 9bd1d9f7) (#40)
- c8fb434f (p1): queue/scheduler healthchecks used pgrep (not installed) → always unhealthy. Now check PID 1 for 'bench worker' / 'bench schedule' — no pgrep. - 9bd1d9f7 (p1): exe-erp-nginx cached the upstream IP and 502'd permanently after exe-erp was recreated. Added Docker DNS resolver (127.0.0.11 valid=10s) + variable proxy_pass to http://exe-erp:8000 so nginx re-resolves per-request — a recreated Frappe container is picked up without an nginx restart. docker compose config passes; git diff --check clean. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5ccf004 commit 34b9d1e

2 files changed

Lines changed: 73 additions & 6 deletions

File tree

docker-compose.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ services:
103103
# closed and visibly disables raw.raw_events emission instead of silently
104104
# guessing credentials. Set to the exedb bridge DSN to enable forwarding.
105105
EXE_BRIDGE_DATABASE_URL: ${EXE_BRIDGE_DATABASE_URL:-}
106-
ports:
107-
- "127.0.0.1:8069:8000"
106+
expose:
107+
- "8000"
108108
volumes:
109109
- erp-sites:/home/frappe/frappe-bench/sites
110110
networks:
@@ -196,10 +196,10 @@ services:
196196
# The RQ worker has no listening port; liveness = the worker process
197197
# is still running. Without this the container can wedge silently and
198198
# background jobs stop processing with no signal (bug 81a9b8ad).
199-
# Uses Python (guaranteed in the image) to scan /proc — no extra apt
199+
# Uses Python (guaranteed in the image) to inspect PID 1 — no extra apt
200200
# deps (procps/pgrep are not installed in the slim base).
201201
healthcheck:
202-
test: ["CMD-SHELL", "python -c \"import glob;import sys;sys.exit(0 if any('worker' in open(f).read() for f in glob.glob('/proc/[0-9]*/cmdline')) else 1)\" 2>/dev/null || exit 1"]
202+
test: ["CMD-SHELL", "python -c \"import sys; cmd=open('/proc/1/cmdline','rb').read().replace(b'\\0', b' '); sys.exit(0 if b'bench worker' in cmd else 1)\""]
203203
interval: 30s
204204
timeout: 10s
205205
retries: 3
@@ -244,15 +244,41 @@ services:
244244
# The scheduler has no listening port; liveness = the schedule process
245245
# is still running. Without this a stalled scheduler stops dispatching
246246
# cron jobs (enqueued_calls, daily/weekly tasks) silently (bug 81a9b8ad).
247-
# Uses Python (guaranteed in the image) to scan /proc — no extra apt
247+
# Uses Python (guaranteed in the image) to inspect PID 1 — no extra apt
248248
# deps (procps/pgrep are not installed in the slim base).
249249
healthcheck:
250-
test: ["CMD-SHELL", "python -c \"import glob;import sys;sys.exit(0 if any('schedule' in open(f).read() for f in glob.glob('/proc/[0-9]*/cmdline')) else 1)\" 2>/dev/null || exit 1"]
250+
test: ["CMD-SHELL", "python -c \"import sys; cmd=open('/proc/1/cmdline','rb').read().replace(b'\\0', b' '); sys.exit(0 if b'bench schedule' in cmd else 1)\""]
251251
interval: 60s
252252
timeout: 10s
253253
retries: 3
254254
start_period: 30s
255255

256+
# -- Nginx reverse proxy ------------------------------------------------
257+
exe-erp-nginx:
258+
image: ghcr.io/askexe/exe-erp:v0.2.0-final8@sha256:2d55a7c30bc6c5240b516de00e75e7384d0e6ec2580691e31cf3cb32ec012b4e
259+
security_opt:
260+
- no-new-privileges:true
261+
cap_drop:
262+
- ALL
263+
entrypoint: []
264+
command: ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]
265+
volumes:
266+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
267+
ports:
268+
- "127.0.0.1:8069:8080"
269+
networks:
270+
- exe-net
271+
depends_on:
272+
exe-erp:
273+
condition: service_healthy
274+
restart: unless-stopped
275+
healthcheck:
276+
test: ["CMD-SHELL", "curl -sf http://localhost:8080/api/method/ping || exit 1"]
277+
interval: 30s
278+
timeout: 10s
279+
retries: 3
280+
start_period: 30s
281+
256282
# ── Volumes ──────────────────────────────────────────────────
257283
volumes:
258284
erp-sites:

nginx.conf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
pid /tmp/nginx.pid;
2+
error_log /dev/stderr warn;
3+
4+
events {
5+
worker_connections 1024;
6+
}
7+
8+
http {
9+
access_log /dev/stdout;
10+
client_body_temp_path /tmp/nginx-client-body;
11+
proxy_temp_path /tmp/nginx-proxy;
12+
fastcgi_temp_path /tmp/nginx-fastcgi;
13+
uwsgi_temp_path /tmp/nginx-uwsgi;
14+
scgi_temp_path /tmp/nginx-scgi;
15+
16+
resolver 127.0.0.11 valid=10s ipv6=off;
17+
18+
map $http_upgrade $connection_upgrade {
19+
default upgrade;
20+
'' close;
21+
}
22+
23+
server {
24+
listen 8080;
25+
server_name _;
26+
27+
location / {
28+
set $frappe_upstream http://exe-erp:8000;
29+
proxy_pass $frappe_upstream;
30+
proxy_http_version 1.1;
31+
proxy_set_header Host $host;
32+
proxy_set_header X-Real-IP $remote_addr;
33+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34+
proxy_set_header X-Forwarded-Proto $scheme;
35+
proxy_set_header X-Forwarded-Host $host;
36+
proxy_set_header X-Forwarded-Port $server_port;
37+
proxy_set_header Upgrade $http_upgrade;
38+
proxy_set_header Connection $connection_upgrade;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)