forked from mtusi2026/mtusi2026lab5
Реализация на 5
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Create synthetic local broker credentials, preserving existing settings."""
|
||||
from pathlib import Path
|
||||
import secrets
|
||||
from urllib.parse import quote
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
env=root/'.env.lab5'
|
||||
values=dict(line.split('=',1) for line in env.read_text().splitlines() if '=' in line and not line.startswith('#'))
|
||||
password=values.get('BROKER_PASSWORD')
|
||||
if not password:
|
||||
password=secrets.token_hex(24)
|
||||
with env.open('a') as f: f.write('\nBROKER_PASSWORD='+password+'\n')
|
||||
p=root/'secrets/lab5/broker_url'
|
||||
if p.exists(): p.chmod(0o600)
|
||||
p.write_text('amqp://messenger:'+quote(password,safe='')+'@broker:5672/\n')
|
||||
p.chmod(0o444)
|
||||
print('Local broker credentials ready.')
|
||||
@@ -21,3 +21,5 @@ chmod 444 secrets/lab5/*.pem
|
||||
printf '%s\n' 'Local lab5 settings and synthetic keys ready; existing files preserved.'
|
||||
|
||||
python3 scripts/bootstrap-storage.py
|
||||
|
||||
python3 scripts/bootstrap-broker.py
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
./scripts/compose.sh stop api lb
|
||||
./scripts/compose.sh restart postgres redis s3
|
||||
./scripts/compose.sh stop api lb worker dispatcher
|
||||
./scripts/compose.sh restart postgres redis s3 broker
|
||||
./scripts/compose.sh run --rm -T s3-init
|
||||
./scripts/compose.sh up -d --wait --wait-timeout 90 api lb
|
||||
./scripts/compose.sh up -d --wait --wait-timeout 90 api lb worker dispatcher
|
||||
|
||||
Reference in New Issue
Block a user