Files
homm/.env.example
apuc e1cc6dbaad Add exchange monitoring controls: stop sync and admin alerts
Stop a running exchange:
- SyncRun gets a Celery task_id and a "stopped" status
- The task is bound and passes its id into the run, so the admin can
  revoke it with app.control.revoke(..., terminate=True)
- Admin action "Stop synchronization" reports stopped, already finished,
  runs without a task id and broker errors separately
- A stopped run is never overwritten by the task result

Alerts about exchange failures:
- NotificationSettings singleton (admin section): on/off, email
  recipients, Telegram bot token and chat id, per-event flags
- notifications.py sends through email and Telegram, best effort:
  delivery errors are logged and never break the exchange
- Fired on catalog apply failure (pull from 1C and inbound push) and on
  outbox messages that exhausted retries
- Admin action "Send test notification" verifies the channels
- SMTP settings added to base.py and .env.example so email really works
  in production; SMS is not implemented (no SMS gateway in the project)

Tests: 11 new cases (email/Telegram delivery, flags, outbox dead-letter,
stop semantics); the suite is 33 passing.
2026-11-22 22:19:43 +03:00

56 lines
1.5 KiB
Bash

# --- Django ---
DJANGO_SETTINGS_MODULE=config.settings.dev
DJANGO_SECRET_KEY=change-me-in-production
DJANGO_DEBUG=true
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1
# --- Database ---
# sqlite | postgres
DB_ENGINE=sqlite
POSTGRES_DB=homm
POSTGRES_USER=homm
POSTGRES_PASSWORD=homm
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
# --- Redis / Celery ---
REDIS_URL=redis://localhost:6379/0
CELERY_BROKER_URL=redis://localhost:6379/0
CELERY_RESULT_BACKEND=redis://localhost:6379/1
# --- CORS ---
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173
# --- Auth / OTP ---
OTP_TTL_SECONDS=300
OTP_MAX_ATTEMPTS=5
# Only for local development: fixed OTP code. Leave empty in production.
OTP_DEBUG_CODE=0000
# --- 1C integration ---
# Shared secret used by 1C when calling the site integration API.
INTEGRATION_API_TOKEN=dev-integration-token
# Base URL of the 1C HTTP service (outbound calls from the site).
ONEC_BASE_URL=http://1c.local/homm/hs/homm
ONEC_USERNAME=
ONEC_PASSWORD=
ONEC_TIMEOUT=30
# --- Email ---
# Console backend prints letters to stdout. For real delivery (alerts about
# exchange failures, password resets) use the SMTP backend and fill the fields below.
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
# EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
DEFAULT_FROM_EMAIL=noreply@homm.local
EMAIL_HOST=
EMAIL_PORT=587
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_USE_TLS=true
EMAIL_TIMEOUT=10
# --- Payments ---
YOOKASSA_SHOP_ID=
YOOKASSA_SECRET_KEY=
YOOKASSA_RETURN_URL=http://localhost:3000/checkout/success