make bitcoin health check dependent on blockheight

This commit is contained in:
keyan 2024-03-09 17:56:07 -06:00
parent c32782583f
commit c63622b8a4
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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