Skip to content

Commit 9e95462

Browse files
committed
Add script for testing notifications
1 parent 288fe5f commit 9e95462

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

README.md

+20-4
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ the participation key before expiration.
7070

7171
To receive a notification when the participation key is about to expire, you can do the following:
7272

73-
### Copy the example file
73+
### Copy the Example File
7474

7575
Start by copying the example notification.yml file to the voi/docker-swarm directory:
7676

7777
`cp ~/voi/docker-swarm/notification.yml.example ~/voi/docker-swarm/notification.yml`
7878

79-
### Update the notification.yml file
79+
### Update the notification.yml File
8080

8181
Update the notification.yml file with your preferred notification mechanism by updating the NOTIFICATION_URLS
8282
environment variable. The notification mechanism can be a webhook, email, push, or any other notification mechanism that
@@ -89,22 +89,30 @@ notification, you would set the `NOTIFICATION_URLS` value in the `notification.y
8989
NOTIFICATION_URLS="discord://<webhook_id>/<webhook_token>,pushbullet://<access_token>"
9090
```
9191

92-
### Updating notification schedule
92+
### Updating Notification Schedule
9393

9494
To modify the notification schedule, adjust the `- swarm.cronjob.schedule=0 16 * * *` label in the copied example file.
9595
This is by default set to run daily at 4 PM UTC. Adjust this to your preferred time, accounting for your
9696
timezone's UTC offset. Use a resource like [dateful.com](https://dateful.com/time-zone-converter) for timezone conversion.
9797

9898
The format of the schedule is following the standard [cronjob format](https://en.wikipedia.org/wiki/Cron#Overview).
9999

100-
### Applying notification configuration to the stack
100+
### Applying Notification Configuration to the Stack
101101

102102
To apply your notification configuration to the stack, rerun the installation script:
103103

104104
```bash
105105
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/VoiNetwork/docker-swarm/main/install.sh)"
106106
```
107107

108+
### Testing Your Notification Configuration
109+
110+
To test your notification configuration, you can manually trigger the notification service by running the following command:
111+
112+
```bash
113+
~/voi/bin/notification-test
114+
```
115+
108116
## Setting a Custom Telemetry Name
109117

110118
To set a custom telemetry name, set the VOINETWORK_TELEMETRY_NAME environment variable to your desired name:
@@ -224,6 +232,14 @@ The `get-node-status` command performs checks using:
224232
- `/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).
225233
- `/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).
226234

235+
### Testing Notifications
236+
237+
To test notifications execute the following command:
238+
239+
```bash
240+
~/voi/bin/notification-test
241+
```
242+
227243
## Debugging
228244

229245
### Startup state for services in stack

bin/notification-test

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
container_id=$(docker ps -q -f name=voinetwork_notify)
4+
if [ -z "${container_id}" ]; then
5+
echo "notification container is not running. Please start it first."
6+
exit 1
7+
fi
8+
9+
echo "Sending notification"
10+
docker exec -it "${container_id}" bash -c "curl -sS -X POST --data '{\"title\": \"Voi Participation Key Notification Test\", \"body\": \"Notification test for Voi Network\"}' localhost:5000 >> /dev/null && echo \"Notification sent\""
11+
12+
echo "Note: After making changes to your notification.yml settings file, make sure to rerun the install script."

0 commit comments

Comments
 (0)