This commit is contained in:
pampixz
2026-11-12 14:37:43 +03:00
parent ec540a1a72
commit 6a7f4ec7d4
17 changed files with 749 additions and 24 deletions
+25
View File
@@ -0,0 +1,25 @@
import os
import time
import boto3
from botocore.config import Config
client = boto3.client(
's3', endpoint_url=os.getenv('S3_ENDPOINT', 'http://s3:8333'),
region_name='us-east-1',
aws_access_key_id=os.environ['S3_ACCESS_KEY_ID'],
aws_secret_access_key=os.environ['S3_SECRET_ACCESS_KEY'],
config=Config(connect_timeout=3, read_timeout=5, retries={'max_attempts': 1}),
)
bucket = os.getenv('S3_BUCKET', 'messenger-attachments')
for attempt in range(60):
try:
buckets = [x['Name'] for x in client.list_buckets().get('Buckets', [])]
if bucket not in buckets:
client.create_bucket(Bucket=bucket)
print('Private S3 bucket ready:', bucket)
break
except Exception as exc:
print('Waiting for S3:', str(exc), flush=True)
if attempt == 59:
raise
time.sleep(2)
+18
View File
@@ -0,0 +1,18 @@
@echo off
cd /d "%~dp0.."
echo Restarting PostgreSQL and S3...
docker compose --env-file .env restart postgres s3
if errorlevel 1 exit /b 1
echo Waiting for storage...
timeout /t 12 /nobreak >nul
echo Restarting API replicas and load balancer...
docker compose --env-file .env restart api1 api2 lb
if errorlevel 1 exit /b 1
echo Waiting for API...
timeout /t 5 /nobreak >nul
exit /b 0
+14
View File
@@ -0,0 +1,14 @@
@echo off
cd /d "%~dp0.."
if /I "%TARGET_INSTANCE_ID%"=="api1" (
docker compose --env-file .env stop api1 >nul 2>&1
exit /b %errorlevel%
)
if /I "%TARGET_INSTANCE_ID%"=="api2" (
docker compose --env-file .env stop api2 >nul 2>&1
exit /b %errorlevel%
)
exit /b 1