Persist messenger in PostgreSQL with sessions, cache and recovery evidence

This commit is contained in:
2026-10-16 15:16:17 +03:00
parent 65003b6119
commit be6f10f195
34 changed files with 8920 additions and 55 deletions
+15
View File
@@ -0,0 +1,15 @@
"""Generate local synthetic credentials once. Never prints their values."""
from pathlib import Path
import secrets
root=Path(__file__).resolve().parents[1]
target=root/'.env'
if target.exists():
print('Existing .env preserved')
else:
password=secrets.token_hex(24)
content=f'POSTGRES_PASSWORD={password}\nDATABASE_URL=postgresql://messenger:{password}@db:5432/messenger\nREDIS_URL=redis://cache:6379/0\nCURSOR_SECRET={secrets.token_hex(32)}\nSESSION_TTL_SECONDS=3600\n'
with target.open('x',encoding='utf-8') as f: f.write(content)
try: target.chmod(0o600)
except OSError: pass
print('Created local .env; values not displayed')