fix: plugin duplicate route registration + prestart.sh Python instead of psql + SMTP in docker-compose
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
This commit is contained in:
Executable → Regular
+26
-10
@@ -30,16 +30,32 @@ echo "[prestart] DB migrations completed successfully."
|
||||
# Set crm_runtime password if RUNTIME_DB_PASSWORD is set
|
||||
if [ -n "$RUNTIME_DB_PASSWORD" ]; then
|
||||
echo "[prestart] Setting crm_runtime password..."
|
||||
# Parse the migration DB URL to get psql connection params
|
||||
PGHOST=postgres
|
||||
PGUSER="${POSTGRES_USER:-crm_user}"
|
||||
PGDATABASE="${POSTGRES_DB:-crm_db}"
|
||||
PGPASSWORD="$POSTGRES_PASSWORD"
|
||||
export PGHOST PGUSER PGDATABASE PGPASSWORD
|
||||
psql -c "ALTER ROLE crm_runtime WITH LOGIN PASSWORD '${RUNTIME_DB_PASSWORD}' NOSUPERUSER NOBYPASSRLS;" 2>/dev/null || \
|
||||
echo "[prestart] WARNING: Could not set crm_runtime password (role may not exist yet)"
|
||||
unset PGPASSWORD
|
||||
echo "[prestart] crm_runtime password set."
|
||||
python3 -c "
|
||||
import asyncio
|
||||
import os
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy import text
|
||||
|
||||
async def set_password():
|
||||
db_url = os.environ.get('MIGRATION_DATABASE_URL', os.environ.get('DATABASE_URL', ''))
|
||||
if not db_url:
|
||||
print('[prestart] WARNING: No DB URL for password setup')
|
||||
return
|
||||
engine = create_async_engine(db_url)
|
||||
pwd = os.environ.get('RUNTIME_DB_PASSWORD', '')
|
||||
try:
|
||||
async with engine.begin() as conn:
|
||||
await conn.execute(text(
|
||||
f\"ALTER ROLE crm_runtime WITH LOGIN PASSWORD '{pwd}' NOSUPERUSER NOBYPASSRLS\"
|
||||
))
|
||||
print('[prestart] crm_runtime password set.')
|
||||
except Exception as e:
|
||||
print(f'[prestart] WARNING: Could not set crm_runtime password: {e}')
|
||||
finally:
|
||||
await engine.dispose()
|
||||
|
||||
asyncio.run(set_password())
|
||||
"
|
||||
fi
|
||||
|
||||
echo "[prestart] Starting uvicorn on 0.0.0.0:8000 (workers=1)..."
|
||||
|
||||
Reference in New Issue
Block a user