From cbe6d22c2d26c4493945935a06c85319ccaec9da Mon Sep 17 00:00:00 2001 From: erhan yasar Date: Sat, 11 Apr 2026 17:13:39 +0300 Subject: [PATCH] feat: add healthcheck to execution service and wait condition for consensus Previously the consensus node would start immediately after the execution client container was created, without waiting for its JSON-RPC to become available. On first boot or after a restart, this caused the consensus service to crash-loop while the execution client was still initialising. Changes: - Add healthcheck to execution service that polls eth_syncing via JSON-RPC. The check passes as soon as the RPC endpoint responds, confirming the client is fully booted (node does not need to be fully synced). - Change depends_on on the node service to condition: service_healthy so the consensus client only starts once the execution client is ready. Healthcheck parameters: interval: 30s - re-poll every 30 seconds timeout: 10s - single-request timeout retries: 5 - mark unhealthy after 5 consecutive failures start_period: 60s - grace window for slow database init on first boot Backwards-compatible: no changes to .env files or entrypoints required. --- docker-compose.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 83d2c4c1..874c3e70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,13 +17,20 @@ services: - USE_BASE_CONSENSUS=${USE_BASE_CONSENSUS:-false} env_file: - ${NETWORK_ENV:-.env.mainnet} # Use .env.mainnet by default, override with .env.sepolia for testnet + healthcheck: + test: ["CMD", "sh", "-c", "curl -sf -X POST -H 'Content-Type: application/json' --data '{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\",\"params\":[],\"id\":1}' http://localhost:8545"] + interval: 30s + timeout: 10s + retries: 5 + start_period: 60s node: build: context: . dockerfile: ${CLIENT:-geth}/Dockerfile restart: unless-stopped depends_on: - - execution + execution: + condition: service_healthy ports: - "7545:8545" # RPC - "9222:9222" # P2P TCP