From 7315cced8a87cc7db35c2d59f10b7aeda6466df7 Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Wed, 8 May 2024 10:56:58 -0400 Subject: [PATCH] fix(litestream): restore from litestream on startup --- litestream/docker-entrypoint.sh | 6 ++++++ src/config.ts | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/litestream/docker-entrypoint.sh b/litestream/docker-entrypoint.sh index 6f9d993..88c4ccb 100644 --- a/litestream/docker-entrypoint.sh +++ b/litestream/docker-entrypoint.sh @@ -4,4 +4,10 @@ set -e # Update env vars ytt --data-values-env TVAL -f /litestream.template.yaml > /litestream.yml +# restore if needed +echo "Restoring database from backup..." +/usr/local/bin/litestream restore -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db +/usr/local/bin/litestream restore -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db + +echo "Starting Litestream for continuous replication..." /usr/local/bin/litestream replicate -config /litestream.yml diff --git a/src/config.ts b/src/config.ts index d891ba8..3bbb469 100644 --- a/src/config.ts +++ b/src/config.ts @@ -19,5 +19,10 @@ export const arnsContractTxId = 'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U'; export const prefetchContractTxIds: string[] = process.env.PREFETCH_CONTRACT_IDS - ? [arnsContractTxId, ...process.env.PREFETCH_CONTRACT_IDS.split(',')] + ? [ + ...new Set([ + arnsContractTxId, + ...process.env.PREFETCH_CONTRACT_IDS.split(','), + ]), + ] // filter out any duplicates : [arnsContractTxId];