Merge pull request #4278 from mempool/knorrium/add_sync_check_script

ops: Add block height workflow
This commit is contained in:
wiz 2024-03-06 16:18:46 +09:00 committed by GitHub
commit c4a11309fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,19 @@
name: 'Check if servers are in sync'
on: [workflow_dispatch]
jobs:
print-backend-sha:
runs-on: 'ubuntu-latest'
name: Get block height
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: repo
- name: Run script
working-directory: repo
run: |
chmod +x ./scripts/get_block_tip_height.sh
sh ./scripts/get_block_tip_height.sh

View File

@ -0,0 +1,25 @@
BASE_HEIGHT=$(curl -sk https://node202.tk7.mempool.space/api/v1/blocks/tip/height)
IN_SYNC=true
echo "Base height (node202.tk7): $BASE_HEIGHT"
for LOCATION in fmt va1 fra tk7
do
for NODE in 201 202 203 204 205 206
do
NODE_HEIGHT=$(curl -sk https://node$NODE.$LOCATION.mempool.space/api/v1/blocks/tip/height)
echo $(echo node$NODE.$LOCATION.mempool.space) - $NODE_HEIGHT
if [ "$NODE_HEIGHT" -ne "$BASE_HEIGHT" ]; then
COUNT=$((BASE_HEIGHT-NODE_HEIGHT))
echo $(echo node$NODE.$LOCATION.mempool.space) is not in sync. delta: $COUNT
IN_SYNC=false
fi
done
done
if [ "$IN_SYNC" = false ]; then
echo "One or more servers are out of sync. Check the logs."
exit -1
else
echo "All servers are in sync."
fi