mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
Auto re-seed bulldozer-js from Postgres during restart-deps (#1745)
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E Fallback Tests / E2E Fallback Tests (Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Lint & build / lint_and_build (24) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
DB migration compat / Check if migrations changed (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E Fallback Tests / E2E Fallback Tests (Node ${{ matrix.node-version }}) (22.x) (push) Has been cancelled
Lint & build / lint_and_build (24) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
DB migration compat / Back-compat — Current branch migrations with ${{ needs.check-migrations-changed.outputs.base_branch }} branch code (push) Has been cancelled
DB migration compat / Forward-compat — Current branch code with ${{ needs.check-migrations-changed.outputs.base_branch }} branch migrations (push) Has been cancelled
DB migration compat / No migration changes (skipped) (push) Has been cancelled
This commit is contained in:
parent
a53a5243aa
commit
f44d5d9bba
@ -29,7 +29,8 @@
|
||||
"wait-until-postgres-is-ready:pg_isready": "until pg_isready -h localhost -p ${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX:-81}28 && pg_isready -h localhost -p ${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX:-81}34; do sleep 1; done",
|
||||
"wait-until-postgres-is-ready": "command -v pg_isready >/dev/null 2>&1 && pnpm run wait-until-postgres-is-ready:pg_isready || sleep 10",
|
||||
"wait-until-clickhouse-is-ready": "echo 'Waiting for ClickHouse to be ready...' && pnpm exec wait-on -t 10000 -v http-get://localhost:${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX:-81}36/ping || echo 'ClickHouse is not ready after 10 seconds (this is probably a problem with our wait-on setup TODO fix), continuing regardless...'",
|
||||
"start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"",
|
||||
"start-deps:no-delay": "pnpm pre && pnpm run deps-compose up --detach --build && pnpm run wait-until-postgres-is-ready && pnpm run wait-until-clickhouse-is-ready && pnpm run db:init && pnpm run reseed-bulldozer && echo \"\\nDependencies started in the background as Docker containers. 'pnpm run stop-deps' to stop them\"",
|
||||
"reseed-bulldozer": "pnpm pre && bash scripts/reseed-bulldozer.sh",
|
||||
"start-deps": "POSTGRES_DELAY_MS=${POSTGRES_DELAY_MS:-0} pnpm run start-deps:no-delay",
|
||||
"restart-deps": "pnpm pre && pnpm run stop-deps && pnpm run start-deps",
|
||||
"restart-deps:no-delay": "pnpm pre && pnpm run stop-deps && pnpm run start-deps:no-delay",
|
||||
|
||||
43
scripts/reseed-bulldozer.sh
Executable file
43
scripts/reseed-bulldozer.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Re-seed the bulldozer-js payments store from Postgres as part of restart-deps.
|
||||
#
|
||||
# Why this exists: bulldozer-js keeps its state in an on-disk LMDB store that
|
||||
# lives OUTSIDE Docker, so stop-deps/start-deps (which only reset the Docker
|
||||
# containers) leave a stale bulldozer store behind. After a fresh Postgres seed
|
||||
# that store is inconsistent, which is why we previously had to manually wipe
|
||||
# apps/bulldozer-js/.data and re-run db:backfill-bulldozer-from-prisma every
|
||||
# time. This script does that automatically: wipe the store, boot a temporary
|
||||
# bulldozer-js, run the one-way Postgres->bulldozer backfill against it, then
|
||||
# shut it back down again.
|
||||
set -euo pipefail
|
||||
|
||||
PORT_PREFIX="${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX:-81}"
|
||||
BULLDOZER_PORT="${PORT_PREFIX}46"
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BULLDOZER_DIR="$REPO_ROOT/apps/bulldozer-js"
|
||||
|
||||
echo "Wiping bulldozer-js LMDB store at $BULLDOZER_DIR/.data ..."
|
||||
rm -rf "$BULLDOZER_DIR/.data"
|
||||
|
||||
echo "Starting temporary bulldozer-js on port $BULLDOZER_PORT ..."
|
||||
# Run the server directly (single node process, so we can reliably kill it) via
|
||||
# tsx's node loader — the same entrypoint the package's `start` script uses.
|
||||
(
|
||||
cd "$BULLDOZER_DIR" && exec node --import tsx --expose-gc src/index.ts
|
||||
) &
|
||||
BULLDOZER_PID=$!
|
||||
|
||||
cleanup() {
|
||||
echo "Shutting down temporary bulldozer-js (pid $BULLDOZER_PID) ..."
|
||||
kill "$BULLDOZER_PID" 2>/dev/null || true
|
||||
wait "$BULLDOZER_PID" 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Waiting for bulldozer-js to accept connections on port $BULLDOZER_PORT ..."
|
||||
pnpm exec wait-on -t 60000 "tcp:localhost:$BULLDOZER_PORT"
|
||||
|
||||
echo "Running Postgres->bulldozer backfill ..."
|
||||
pnpm run db:backfill-bulldozer-from-prisma
|
||||
|
||||
echo "Bulldozer re-seed complete."
|
||||
Loading…
Reference in New Issue
Block a user