Merge branch 'txoo_health' into 'main'
txoo: healthcheck See merge request lightning-signer/vls-container!14
This commit is contained in:
commit
c2e1c07bb3
@ -54,4 +54,4 @@ compose:
|
|||||||
- ./scripts/build_from_cache.sh lightningd
|
- ./scripts/build_from_cache.sh lightningd
|
||||||
- ./scripts/build_from_cache.sh txood
|
- ./scripts/build_from_cache.sh txood
|
||||||
- ./scripts/build_from_cache.sh vlsd
|
- ./scripts/build_from_cache.sh vlsd
|
||||||
- docker compose --profile vls up -d --wait --wait-timeout 120 --build
|
- docker compose --profile vls -f docker-compose.yml -f docker-compose.regtest.yml up -d --wait --wait-timeout 120 --build
|
||||||
|
@ -37,9 +37,6 @@ Below are the steps required to run `vlsd2` as a standalone container.
|
|||||||
### Docker Image
|
### Docker Image
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull the latest release image for vlsd
|
|
||||||
docker pull registry.gitlab.com/lightning-signer/vls-container/vlsd:latest
|
|
||||||
docker tag registry.gitlab.com/lightning-signer/vls-container/vlsd:latest vlsd:latest
|
|
||||||
# Build the latest docker image
|
# Build the latest docker image
|
||||||
cd vlsd
|
cd vlsd
|
||||||
docker build -t vlsd .
|
docker build -t vlsd .
|
||||||
|
@ -1 +1,15 @@
|
|||||||
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [[ "$BITCOIN_CHAIN" = "regtest" ]]; then
|
||||||
|
# Check if the wallet already exists
|
||||||
|
if ! bitcoin-cli listwallets | grep -q "default"; then
|
||||||
|
# If the wallet does not exist, create it
|
||||||
|
bitcoin-cli createwallet default
|
||||||
|
fi
|
||||||
|
block_count=$(bitcoin-cli -chain=$BITCOIN_CHAIN getblockcount)
|
||||||
|
if [[ "$block_count" = "0" ]]; then
|
||||||
|
bitcoin-cli generatetoaddress 101 $(bitcoin-cli -chain=$BITCOIN_CHAIN getnewaddress)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
bitcoin-cli -chain=$BITCOIN_CHAIN getblockchaininfo
|
||||||
|
@ -32,10 +32,9 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- txoo_regtest:/root/.txoo/
|
- txoo_regtest:/root/.txoo/
|
||||||
- bitcoin_regtest:/root/.bitcoin/
|
- bitcoin_regtest:/root/.bitcoin/
|
||||||
command:
|
|
||||||
- -r http://rpcuser:VLSsigner1@bitcoind:38332
|
|
||||||
environment:
|
environment:
|
||||||
- BITCOIN_NETWORK=regtest
|
- BITCOIN_NETWORK=regtest
|
||||||
|
- BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:38332
|
||||||
|
|
||||||
vls:
|
vls:
|
||||||
container_name: vlsd-regtest
|
container_name: vlsd-regtest
|
||||||
|
@ -47,8 +47,6 @@ services:
|
|||||||
image: txood:${IMAGE_TAG:-latest}
|
image: txood:${IMAGE_TAG:-latest}
|
||||||
container_name: txood-test
|
container_name: txood-test
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command:
|
|
||||||
- -r http://rpcuser:VLSsigner1@bitcoind:18332
|
|
||||||
networks:
|
networks:
|
||||||
- lightning
|
- lightning
|
||||||
volumes:
|
volumes:
|
||||||
@ -59,6 +57,7 @@ services:
|
|||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
- BITCOIN_NETWORK=testnet
|
- BITCOIN_NETWORK=testnet
|
||||||
|
- BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332
|
||||||
|
|
||||||
vls:
|
vls:
|
||||||
build:
|
build:
|
||||||
|
@ -30,14 +30,22 @@ RUN apk update && \
|
|||||||
build-base \
|
build-base \
|
||||||
bind-tools \
|
bind-tools \
|
||||||
libev-dev \
|
libev-dev \
|
||||||
curl-dev
|
curl-dev \
|
||||||
|
curl \
|
||||||
|
jq
|
||||||
|
|
||||||
COPY --from=builder /usr/local/bin/txood /usr/bin/txood
|
COPY --from=builder /usr/local/bin/txood /usr/bin/txood
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
COPY healthcheck.sh /healthcheck.sh
|
||||||
|
RUN chmod +x /healthcheck.sh
|
||||||
|
|
||||||
VOLUME ["${TXOO_DATA}"]
|
VOLUME ["${TXOO_DATA}"]
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=5s --timeout=10s --start-period=5s \
|
||||||
|
CMD ["/bin/sh", "-c", "/healthcheck.sh"]
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
CMD ["txood"]
|
CMD ["txood"]
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
if [ $(echo "$1" | cut -c1) = "-" ]; then
|
if [ $(echo "$1" | cut -c1) = "-" ]; then
|
||||||
echo "$0: assuming arguments for txood"
|
echo "$0: assuming arguments for txood"
|
||||||
|
|
||||||
set -- txood --network $BITCOIN_NETWORK "$@"
|
set -- txood "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "txood" ]; then
|
||||||
|
echo "$0: setting network to $BITCOIN_NETWORK"
|
||||||
|
echo "$0: setting RPC URL to $BITCOIND_RPC_URL"
|
||||||
|
|
||||||
|
set -- "$@" --network $BITCOIN_NETWORK -r $BITCOIND_RPC_URL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
27
txood/healthcheck.sh
Normal file
27
txood/healthcheck.sh
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# Get the latest file with extension .sa from /root/.txoo/$BITCOIN_NETWORK/public directory and get the block number from the file name
|
||||||
|
TXOO_LOCATION=/root/.txoo/$BITCOIN_NETWORK/public
|
||||||
|
latest_block=$(ls -r1t $TXOO_LOCATION | grep '.sa' | head -n1 | cut -d'-' -f1)
|
||||||
|
|
||||||
|
# Check if no file was found
|
||||||
|
if [ -z "$latest_block" ]; then
|
||||||
|
echo "No file found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert latest_block to a number
|
||||||
|
latest_block=$(expr $latest_block + 0)
|
||||||
|
|
||||||
|
# Get the block count from bitcoind
|
||||||
|
bitcoind_block_count=$(curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' $BITCOIND_RPC_URL | jq .result)
|
||||||
|
|
||||||
|
blocks_behind=$((bitcoind_block_count - latest_block))
|
||||||
|
|
||||||
|
# Check if the latest attestation is more than 1 block behind
|
||||||
|
if [[ $blocks_behind -gt 1 ]]; then
|
||||||
|
echo "The latest attestation is more than 1 block behind" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user