forked from mtusi2026/mtusi2026lab3
Выполнена лабораторная работа 3
This commit is contained in:
@@ -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.')
|
||||
Reference in New Issue
Block a user