Skip to content

Commit 4b11777

Browse files
committed
Add participation key expiration notification service
1 parent 2fdb46c commit 4b11777

File tree

5 files changed

+99
-20
lines changed

5 files changed

+99
-20
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
./.idea/**/*
2+
3+
/docker-swarm/notification.yml

README.md

+36-6
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,42 @@ expire, rerun the installation script to generate a new key.
6161
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/VoiNetwork/docker-swarm/main/install.sh)"
6262
```
6363

64+
## Setting Participation Key Expiry Notification (Recommended, Optional)
65+
66+
Each online account has a participation key that needs to be valid for the account to participate in the Voi network.
67+
A participation key is valid for a certain number of rounds, which is approximately 14 days. When the participation key
68+
expires the node runner will no longer be able to propose or vote on blocks. To avoid this situation you need to renew
69+
the participation key before expiration.
70+
71+
To receive a notification when the participation key is about to expire, you can do the following:
72+
73+
### Copy the example file
74+
75+
Start by copying the example notification.yml file to the voi/docker-swarm directory:
76+
77+
`cp ~/voi/docker-swarm/notification.yml.example ~/voi/docker-swarm/notification.yml`
78+
79+
### Update the notification.yml file
80+
81+
Update the notification.yml file with your preferred notification mechanism by updating the NOTIFICATION_URLS
82+
environment variable. The notification mechanism can be a webhook, email, push, or any other notification mechanism that
83+
is available via [Apprise notifications](https://github.com/caronc/apprise?tab=readme-ov-file#supported-notifications)
84+
85+
If you want to use multiple mechanisms, separate them with a comma. For example, to use both Discord and Pushbullet for
86+
notification, you would set the `NOTIFICATION_URLS` value in the `notification.yml` file to:
87+
88+
```yaml
89+
NOTIFICATION_URLS="discord://<webhook_id>/<webhook_token>,pushbullet://<access_token>"
90+
```
91+
92+
### Updating notification schedule
93+
94+
To modify the notification schedule, adjust the `- swarm.cronjob.schedule=0 16 * * *` label in the copied example file.
95+
This is by default set to run daily at 4 PM UTC. Adjust this to your preferred time, accounting for your
96+
timezone's UTC offset. Use a resource like [dateful.com](https://dateful.com/time-zone-converter) for timezone conversion.
97+
98+
The format of the schedule is following the standard [cronjob format](https://en.wikipedia.org/wiki/Cron#Overview).
99+
64100
## Setting a Custom Telemetry Name
65101

66102
To set a custom telemetry name, set the VOINETWORK_TELEMETRY_NAME environment variable to your desired name:
@@ -197,9 +233,3 @@ The `get-node-status` command performs checks using:
197233
### Inspect service
198234

199235
`docker inspect voinetwork_algod`
200-
201-
## TODO
202-
203-
- [ ] Add apprise / alarming on scaling events in docker-compose.yml
204-
- [ ] Add script for participation key management
205-
- [ ] Add mechanism for a user to specify notification mechanism for key expiration

docker-swarm/compose.yml

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
version: "3.8"
22
services:
33
algod:
4-
build: ..
54
image: ghcr.io/voinetwork/docker-participation-node:latest
6-
volumes:
7-
- /var/lib/voi/algod/data:/algod/data/:rw
85
environment:
96
TELEMETRY_NAME: ${VOINETWORK_TELEMETRY_NAME}
107
logging:
118
driver: "local"
9+
volumes:
10+
- /var/lib/voi/algod/data:/algod/data/:rw
1211
deploy:
1312
replicas: 1
1413
restart_policy:
1514
condition: on-failure
15+
networks:
16+
- notification
1617
shepherd:
17-
build: ..
1818
image: containrrr/shepherd
1919
environment:
2020
RUN_ONCE_AND_EXIT: "true"
21+
ROLLBACK_ON_FAILURE: "true"
22+
IMAGE_AUTOCLEAN_LIMIT: "5"
2123
logging:
2224
driver: "local"
2325
volumes:
@@ -28,22 +30,25 @@ services:
2830
condition: none
2931
labels:
3032
- swarm.cronjob.enable=true
31-
- swarm.cronjob.schedule=0 0 * * *
33+
- swarm.cronjob.schedule=0 16 * * *
3234
- swarm.cronjob.skip-running=true
3335
placement:
3436
constraints:
3537
- node.role == manager
3638
scheduler:
37-
image: crazymax/swarm-cronjob:latest
39+
image: ghcr.io/voinetwork/swarm-cronjob:edge
3840
logging:
3941
driver: "local"
40-
volumes:
41-
- /var/run/docker.sock:/var/run/docker.sock:ro
4242
environment:
43-
- "TZ=Europe/London"
43+
- "TZ=UTC"
4444
- "LOG_LEVEL=info"
4545
- "LOG_JSON=false"
46+
volumes:
47+
- /var/run/docker.sock:/var/run/docker.sock:ro
4648
deploy:
4749
placement:
4850
constraints:
4951
- node.role == manager
52+
53+
networks:
54+
notification:

docker-swarm/notification.yml.example

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "3.8"
2+
services:
3+
notify:
4+
image: mazzolino/apprise-microservice:0.2
5+
environment:
6+
## Reference https://github.com/caronc/apprise?tab=readme-ov-file#productivity-based-notifications supported formats and setup
7+
NOTIFICATION_URLS: discord://.....,slack://.....,pbul://
8+
logging:
9+
driver: "local"
10+
networks:
11+
- notification
12+
partkey_checker:
13+
image: ghcr.io/voinetwork/docker-swarm-partkey-monitoring:edge
14+
logging:
15+
driver: "local"
16+
volumes:
17+
- /var/lib/voi/algod/data/voitest-v1/:/voi/:rw
18+
networks:
19+
- notification
20+
depends_on:
21+
- notify
22+
deploy:
23+
replicas: 0
24+
restart_policy:
25+
condition: none
26+
labels:
27+
- swarm.cronjob.enable=true
28+
- swarm.cronjob.skip-running=true
29+
- swarm.cronjob.schedule=0 16 * * *

install.sh

+17-5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ start_docker_swarm() {
8383
fi
8484
}
8585

86+
start_stack() {
87+
command="env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${voi_home}/docker-swarm/compose.yml"
88+
89+
if [[ -f "${voi_home}/docker-swarm/notification.yml" ]]; then
90+
command+=" -c ${voi_home}/docker-swarm/notification.yml"
91+
fi
92+
93+
command+=" voinetwork"
94+
execute_sudo "$command"
95+
96+
# shellcheck disable=SC2181
97+
if [[ $? -ne 0 ]]; then
98+
abort "Error starting stack. Exiting the program."
99+
fi
100+
}
101+
86102
wait_for_stack_to_be_ready() {
87103
while true; do
88104
service_info=$(execute_sudo 'docker stack ps voinetwork --format json' | grep 'voinetwork_algod')
@@ -563,11 +579,7 @@ curl -L https://api.github.com/repos/VoiNetwork/docker-swarm/tarball/main --outp
563579
tar -xzf "${voi_home}"/docker-swarm.tar.gz -C "${voi_home}" --strip-components=1
564580
rm "${voi_home}"/docker-swarm.tar.gz
565581

566-
execute_sudo "env VOINETWORK_TELEMETRY_NAME=$VOINETWORK_TELEMETRY_NAME docker stack deploy -c ${voi_home}/docker-swarm/compose.yml voinetwork"
567-
# shellcheck disable=SC2181
568-
if [[ $? -ne 0 ]]; then
569-
abort "Error starting stack. Exiting the program."
570-
fi
582+
start_stack
571583

572584
wait_for_stack_to_be_ready
573585

0 commit comments

Comments
 (0)