From 7315cced8a87cc7db35c2d59f10b7aeda6466df7 Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Wed, 8 May 2024 10:56:58 -0400 Subject: [PATCH 1/3] 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]; From 3ad8c9b4f898d54cee33989822c46a9acdc7ee2b Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Wed, 8 May 2024 11:23:00 -0400 Subject: [PATCH 2/3] fix(litestream): only restore if db does not exist --- litestream/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litestream/docker-entrypoint.sh b/litestream/docker-entrypoint.sh index 88c4ccb..a710ad4 100644 --- a/litestream/docker-entrypoint.sh +++ b/litestream/docker-entrypoint.sh @@ -6,8 +6,8 @@ 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 +/usr/local/bin/litestream restore -if-db-not-exists -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db +/usr/local/bin/litestream restore -if-db-not-exists -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db echo "Starting Litestream for continuous replication..." /usr/local/bin/litestream replicate -config /litestream.yml From aac5497edd5a873880649b3876db4dff2cca9fcd Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Wed, 8 May 2024 11:24:42 -0400 Subject: [PATCH 3/3] feat(litestream): add parllelism for restoreation --- litestream/docker-entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litestream/docker-entrypoint.sh b/litestream/docker-entrypoint.sh index a710ad4..5784bca 100644 --- a/litestream/docker-entrypoint.sh +++ b/litestream/docker-entrypoint.sh @@ -6,8 +6,8 @@ ytt --data-values-env TVAL -f /litestream.template.yaml > /litestream.yml # restore if needed echo "Restoring database from backup..." -/usr/local/bin/litestream restore -if-db-not-exists -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db -/usr/local/bin/litestream restore -if-db-not-exists -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db +/usr/local/bin/litestream restore -if-db-not-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/state.db +/usr/local/bin/litestream restore -if-db-not-exists -parallelism 10 -config /litestream.yml $TVAL_LOCAL_DB_PATH/contract.db echo "Starting Litestream for continuous replication..." /usr/local/bin/litestream replicate -config /litestream.yml