ЛР 3 — балансировка и отказ API-реплики
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
"""Generate local Compose secrets once, without printing them."""
|
||||
|
||||
from pathlib import Path
|
||||
from secrets import token_hex
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
example = (root / ".env.example").read_text(encoding="utf-8")
|
||||
try:
|
||||
with (root / ".env").open("x", encoding="utf-8", newline="\n") as target:
|
||||
target.write(example.replace("POSTGRES_PASSWORD=\n", f"POSTGRES_PASSWORD={token_hex(24)}\n")
|
||||
.replace("CURSOR_SECRET=\n", f"CURSOR_SECRET={token_hex(32)}\n"))
|
||||
except FileExistsError:
|
||||
print("Using the existing .env")
|
||||
else:
|
||||
print("Created local .env")
|
||||
Reference in New Issue
Block a user