Skeleton contracts / contracts (pull_request) Blocked by required conditions
30 lines
729 B
Bash
30 lines
729 B
Bash
#!/bin/sh
|
|
set -eu
|
|
python - <<'PY'
|
|
import os
|
|
import time
|
|
|
|
from sqlalchemy import create_engine, text
|
|
|
|
if os.getenv("MIGRATION_CONTEXT") == "1":
|
|
engine = create_engine(os.environ["DATABASE_URL"], connect_args={
|
|
"connect_timeout": 3,
|
|
"sslmode": "verify-full",
|
|
"sslrootcert": os.getenv("DB_CA_FILE", "/run/tls/service-ca.crt"),
|
|
})
|
|
else:
|
|
# Uses this service's scoped AppRole KV path and verifies the DB TLS identity.
|
|
from src.database import engine
|
|
|
|
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
|
|
exec "$@"
|