Skip to content

Commit 2a6a1d1

Browse files
authored
Add basic healthcheck command (#15)
1 parent 3ecb1eb commit 2a6a1d1

6 files changed

+52
-1
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ Open a bash shell in the AVM container with the following command:
155155
~/voi/bin/start-shell
156156
```
157157

158+
### Getting basic node status
159+
160+
To retrieve basic health information about your node, execute the following command:
161+
162+
```bash
163+
~/voi/bin/get-node-status
164+
```
165+
166+
The `get-node-status` command performs checks using:
167+
168+
- `goal node status` to connect to the running daemon and retrieve basic node information
169+
- `/health`: This API endpoint checks the reported health of the node. [REST API /health documentation](https://developer.algorand.org/docs/rest-apis/algod/#get-health).
170+
- `/ready`: This API endpoint checks the reported readiness of the node and if fully caught up. [REST API /ready documentation](https://developer.algorand.org/docs/rest-apis/algod/#get-ready).
171+
158172
## Debugging
159173

160174
### Startup state for services in stack

bin/create-account

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ if [ -z "${container_id}" ]; then
55
echo "AVM container is not running. Please start it first."
66
exit 1
77
fi
8+
89
docker exec -it "${container_id}" goal account new

bin/get-account-mnemonic

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ if [ -z "$1" ]; then
1111
echo "Example: get-account-mnemonic <account_address>"
1212
exit 1
1313
fi
14+
1415
docker exec -e account_addr="$1" -it "${container_id}" bash -c 'goal account export -a $account_addr'

bin/get-node-status

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
container_id=$(docker ps -q -f name=voinetwork_algod)
4+
if [ -z "${container_id}" ]; then
5+
echo "AVM container is not running. Please start it first."
6+
exit 1
7+
fi
8+
9+
declare -A health_checks
10+
11+
if [[ $(docker exec -it "${container_id}" bash -c "goal node status") ]]; then
12+
health_checks["Daemon running"]="true"
13+
else
14+
health_checks["Daemon running"]="false"
15+
fi
16+
17+
if [[ $(docker exec "${container_id}" bash -c "curl -fs http://localhost:8080/health") ]]; then
18+
health_checks["Daemon healthy"]="true"
19+
else
20+
health_checks["Daemon healthy"]="false"
21+
fi
22+
23+
if [[ $(docker exec "${container_id}" bash -c "curl -fs http://localhost:8080/ready") ]]; then
24+
health_checks["Daemon ready (and caught up)"]="true"
25+
else
26+
health_checks["Daemon ready (and caught up)"]="false"
27+
fi
28+
29+
# Print all health checks
30+
echo "Health checks:"
31+
echo "**************"
32+
for check in "${!health_checks[@]}"; do
33+
echo "$check: ${health_checks[$check]}"
34+
done

bin/import-account

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ if [ -z "${container_id}" ]; then
55
echo "AVM container is not running. Please start it first."
66
exit 1
77
fi
8+
89
docker exec -it "${container_id}" goal account import

bin/set-telemetry-name

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ set_telemetry_name
3131

3232
bash -c "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ../docker-swarm/compose.yml voinetwork"
3333

34-
echo "Changes have been applied to the network. Please wait a minute for the changes to take effect."
34+
echo "Changes has been applied to the network. Please wait a minute for the changes to take effect."

0 commit comments

Comments
 (0)