Выполнена лабораторная работа 3

This commit is contained in:
2026-11-12 20:51:39 +03:00
parent 0ab3a341aa
commit 21ad522707
142 changed files with 41889 additions and 50 deletions
+16
View File
@@ -0,0 +1,16 @@
from pathlib import Path
import secrets
root = Path(__file__).resolve().parents[1]
directory = root / 'secrets'
directory.mkdir(exist_ok=True)
password_file = directory / 'db_password'
if not password_file.exists():
password_file.write_text(secrets.token_hex(32), encoding='utf-8')
url_file = directory / 'database_url'
if not url_file.exists():
url_file.write_text('postgresql://messenger:' + password_file.read_text().strip() + '@postgres:5432/messenger', encoding='utf-8')
environment = root / '.env'
if not environment.exists():
environment.write_text('API_REPLICAS=2\nAPI_CPUS=0.5\nAPI_MEMORY=256m\nDB_POOL_SIZE=1\nSESSION_TTL_SECONDS=3600\n', encoding='utf-8')
print('Local configuration prepared; existing credentials preserved.')