chore: import MCTF services
- Added all seven issued service trees without omissions. - Preserved the supplied runtime configuration, binaries, and assets.
This commit is contained in:
commit
13f936bee9
1222 files changed
+21280
No files matched your search
Executable
+27
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
|
||||
import psycopg
|
||||
|
||||
from backend.app.db import bootstrap
|
||||
from backend.app.db.connection import DSN
|
||||
|
||||
STARTUP_ATTEMPTS = 10
|
||||
STARTUP_DELAY = 1.0
|
||||
|
||||
async def initialize():
|
||||
for attempt in range(1, STARTUP_ATTEMPTS + 1):
|
||||
try:
|
||||
async with await psycopg.AsyncConnection.connect(DSN, autocommit=True, connect_timeout=5) as db:
|
||||
async with db.transaction():
|
||||
await db.execute("select pg_advisory_xact_lock(hashtextextended('dark-tariff:bootstrap', 0))")
|
||||
await db.execute(bootstrap.sql())
|
||||
return
|
||||
except psycopg.OperationalError as error:
|
||||
if error.sqlstate and not (error.sqlstate.startswith("08") or error.sqlstate in {"40001", "40P01", "55P03"}):
|
||||
raise
|
||||
if attempt == STARTUP_ATTEMPTS:
|
||||
raise
|
||||
await asyncio.sleep(STARTUP_DELAY)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(initialize())
|
||||
Reference in new issue
Block a user