From c63622b8a450abd73ea21da3a0c0229daeb4f84a Mon Sep 17 00:00:00 2001 From: keyan Date: Sat, 9 Mar 2024 17:56:07 -0600 Subject: [PATCH] make bitcoin health check dependent on blockheight --- .env.sample | 2 +- docker-compose.yml | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.env.sample b/.env.sample index 70f53f9c..7e0f1e30 100644 --- a/.env.sample +++ b/.env.sample @@ -101,7 +101,7 @@ discovery.type=single-node DISABLE_SECURITY_DASHBOARDS_PLUGIN=true # bitcoind container stuff -RPC_AUTH='67a3db6d29c5a1561052cfd98a68d386$30e1de363f5b6eecf54196c1e754dae84f10eadb03804249682579401c86589e' +RPC_AUTH='7c68e5fcdba94a366bfdf629ecc676bb$0d0fc087c3bf7f068f350292bf8de1418df3dd8cb31e35682d5d3108d601002b' RPC_USER=bitcoin RPC_PASS=bitcoin RPC_PORT=18443 diff --git a/docker-compose.yml b/docker-compose.yml index 4180eb9d..2e44be4d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -154,9 +154,18 @@ services: image: polarlightning/bitcoind:26.0 container_name: bitcoin restart: unless-stopped - stop_grace_period: '5m' healthcheck: - test: ["CMD", "bitcoin-cli", "-chain=regtest", "-rpcport=${RPC_PORT}", "-rpcuser=${RPC_USER}", "-rpcpassword=${RPC_PASS}", "getblockchaininfo"] + test: > + bash -c ' + set -e + blockcount=$$(bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} getblockcount 2>/dev/null) + if (( blockcount <= 0 )); then + bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 10 ${LND_ADDR} + bitcoin-cli -chain=regtest -rpcport=${RPC_PORT} -rpcuser=${RPC_USER} -rpcpassword=${RPC_PASS} generatetoaddress 10 ${STACKER_LND_ADDR} + exit 1 + fi + exit 0 + ' interval: 10s timeout: 10s retries: 10