ops: wait for the database on startup (no crash-loop on a slow DB)
New thoughtsync.dbwait polls the DB (SELECT 1) up to 60×1s before startup, logging each attempt, so a briefly slow/unready database no longer crash- loops the container. Wired as `python -m thoughtsync.dbwait &&` ahead of `alembic upgrade head` in the image CMD and the dev compose command; exits non-zero after the window so a restart policy can take over. Prod compose gains restart: unless-stopped as the complementary piece. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -40,9 +40,10 @@ services:
|
||||
- thoughtsync-dev-data:/var/thoughtsync
|
||||
ports:
|
||||
- "5000:5000"
|
||||
# Install deps, run migrations, then serve with live reload on the mounted src.
|
||||
# Install deps, wait for the DB, run migrations, then serve with live reload.
|
||||
command: >
|
||||
sh -c "pip install --quiet -e . &&
|
||||
python -m thoughtsync.dbwait &&
|
||||
alembic upgrade head &&
|
||||
hypercorn 'thoughtsync.app:create_app()' --bind 0.0.0.0:5000 --reload"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user