Complete Lab 5: implementation, fault scenarios, and Track 1 report
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Create local-only secret files once; do not print their values."""
|
||||
from pathlib import Path
|
||||
import secrets
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
d=root/'secrets'; d.mkdir(mode=0o700,exist_ok=True); d.chmod(0o700)
|
||||
def ensure(name,value):
|
||||
p=d/name
|
||||
if not p.exists(): p.write_text(value)
|
||||
p.chmod(0o600)
|
||||
ensure('db_password',secrets.token_urlsafe(32))
|
||||
ensure('rustfs_root_user','RUSTFSROOT')
|
||||
ensure('rustfs_root_password',secrets.token_urlsafe(32))
|
||||
ensure('s3_access_key_id','messengerapi')
|
||||
ensure('s3_secret_access_key',secrets.token_urlsafe(40))
|
||||
p=d/'database_url'; ensure('database_url','postgresql://messenger:'+ (d/'db_password').read_text().strip()+'@postgres:5432/messenger')
|
||||
ensure('cache_url','redis://redis:6379/0')
|
||||
ensure('broker_url','redis://broker:6379/0')
|
||||
env=root/'.env'
|
||||
if not env.exists(): env.write_text('API_REPLICAS=2\nAPP_PORT=8081\nSESSION_TTL_SECONDS=3600\nWORKER_CONCURRENCY=2\nMAX_QUEUED_JOBS=500\nJOB_MAX_ATTEMPTS=5\nJOB_TIMEOUT_SECONDS=60\n')
|
||||
env.chmod(0o600)
|
||||
print('Local secrets created or preserved; values hidden.')
|
||||
Reference in New Issue
Block a user