- X-Instance-Id в каждом ответе; обязательный Idempotency-Key, таблица idempotency_keys (миграция 0002, одна транзакция, конкурентные повторы через уникальный индекс) - graceful shutdown: SIGTERM -> ready=503 -> drain 3 с -> закрытие порта - compose: lb (HAProxy) + api x2 без портов + разовый migrate + postgres, лимиты CPU/RAM - хуки stop-one/restart/restore-replicas, scripts/experiments.py (failover, idempotency, rolling) - свои тесты: 44 (13 новых); evidence: smoke, pytest, persistence, failover, эксперименты
38 lines
2.0 KiB
Bash
38 lines
2.0 KiB
Bash
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
|
|
# Names follow pydantic-settings: prefix APP_CONFIG__, nesting via "__" (see app/core/config.py).
|
|
# Mapping to the skeleton's logical names: APP_HOST -> APP_CONFIG__RUN__HOST, APP_PORT -> APP_CONFIG__RUN__PORT,
|
|
# DATABASE_URL_FILE -> APP_CONFIG__DB__* (host/port/name/user + password file),
|
|
# SESSION_TTL_SECONDS -> APP_CONFIG__JWT__SESSION_TTL_SECONDS, SESSION_STORE=postgres (sessions table),
|
|
# IDEMPOTENCY_TTL_SECONDS -> APP_CONFIG__IDEMPOTENCY__TTL_SECONDS, API_REPLICAS -> API_REPLICAS (compose.yaml).
|
|
APP_CONFIG__RUN__HOST=0.0.0.0
|
|
APP_CONFIG__RUN__PORT=8080
|
|
APP_CONFIG__LOGGING__LEVEL=INFO
|
|
|
|
# PostgreSQL. Values below are for running the API from the venv on the host;
|
|
# inside Compose the defaults (host=postgres, /run/secrets/postgres_password) are used.
|
|
APP_CONFIG__DB__HOST=127.0.0.1
|
|
APP_CONFIG__DB__PORT=5432
|
|
APP_CONFIG__DB__NAME=messenger
|
|
APP_CONFIG__DB__USER=messenger
|
|
# Path only, never the password itself. Relative paths are resolved from the project root.
|
|
APP_CONFIG__DB__PASSWORD_FILE=secrets/postgres_password
|
|
|
|
# Sessions: JWT signed with a key from a secret file + server-side session row in PostgreSQL
|
|
# (shared by all API replicas, so no sticky sessions are needed).
|
|
APP_CONFIG__JWT__SECRET_FILE=secrets/jwt_secret
|
|
APP_CONFIG__JWT__SESSION_TTL_SECONDS=3600
|
|
|
|
# Idempotency-Key: a repeat within this window returns the original message (contract: 24 h).
|
|
APP_CONFIG__IDEMPOTENCY__TTL_SECONDS=86400
|
|
|
|
# Graceful shutdown: after SIGTERM /health/ready answers 503 for DRAIN seconds, then the port closes
|
|
# and in-flight requests get GRACEFUL seconds. DRAIN must exceed the LB detection time (fall*inter + check timeout = 2.5 s).
|
|
APP_CONFIG__RUN__DRAIN_SECONDS=3
|
|
APP_CONFIG__RUN__GRACEFUL_TIMEOUT=5
|
|
|
|
# Used by compose.yaml.
|
|
# Host port for PostgreSQL (bound to 127.0.0.1 only); API replicas publish no ports at all.
|
|
POSTGRES_HOST_PORT=5432
|
|
# Number of API replicas behind the load balancer.
|
|
API_REPLICAS=2
|