run cleanupjob on fly (#35)

* clippy+fmt

* poor-man's integration of cleanup job

- runs every 5 hours
- deletes all but 2mn slots

* change slots back
This commit is contained in:
Groovie | Mango 2024-01-05 11:12:44 +01:00 committed by GitHub
parent 7a3480e044
commit f877a3a0a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -22,4 +22,4 @@ COPY --from=build /app/target/release/grpc_banking_transactions_notifications /u
COPY --from=build /app/target/release/cleanupdb /usr/local/bin/
COPY --from=build /app/alts.txt /usr/local/bin/
CMD grpc_banking_transactions_notifications --rpc-url "$RPC_URL" --grpc-address-to-fetch-blocks "$GEYSER_GRPC_ADDRESS" --grpc-x-token "$GEYSER_GRPC_X_TOKEN" --banking-grpc-addresses "$LIST_OF_BANKING_STAGE_GRPCS" -a /usr/local/bin/alts.txt
CMD run-service-and-cleanup.sh

19
run-service-and-cleanup.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# bring down whole process tree on exit
trap "kill 0" EXIT
# 432000 = 1 epoch
declare -i SLOTS_TO_KEEP=432000*2
# setup endless loop to run cleanupdb and put it in background
while true; do
# startup delay
sleep 300;
# should retain about 1 week of data
RUST_LOG=info /usr/local/bin/cleanupdb --num-slots-to-keep $SLOTS_TO_KEEP;
# every 5 hours
sleep 18000;
done &
/usr/local/bin/grpc_banking_transactions_notifications --rpc-url "$RPC_URL" --grpc-address-to-fetch-blocks "$GEYSER_GRPC_ADDRESS" --grpc-x-token "$GEYSER_GRPC_X_TOKEN" --banking-grpc-addresses "$LIST_OF_BANKING_STAGE_GRPCS" -a /usr/local/bin/alts.txt