20 lines
456 B
Bash
20 lines
456 B
Bash
#!/bin/sh
|
|
set -eu
|
|
python - <<'PY'
|
|
import os, time
|
|
from sqlalchemy import create_engine, text
|
|
url = os.environ["DATABASE_URL"]
|
|
engine = create_engine(url, connect_args={"connect_timeout": 3})
|
|
for attempt in range(60):
|
|
try:
|
|
with engine.connect() as connection:
|
|
connection.execute(text("SELECT 1"))
|
|
break
|
|
except Exception:
|
|
if attempt == 59:
|
|
raise
|
|
time.sleep(1)
|
|
PY
|
|
alembic upgrade head
|
|
exec "$@"
|