Add monitoring TG service

This commit is contained in:
Grendgi
2026-06-04 14:55:41 +03:00
commit f9e072774c
74 changed files with 7232 additions and 0 deletions

54
.env.example Normal file
View File

@@ -0,0 +1,54 @@
# Telegram MTProto credentials — get from https://my.telegram.org
TG_API_ID=
TG_API_HASH=
TG_PHONE=
# --- ONE OF THE TWO BELOW IS REQUIRED ---
# Preferred (no volumes, k8s-friendly): get the string by running
# docker compose run --rm -it app python -m parser_bot.auth
# It prints `TG_SESSION_STRING=...` — paste that line here.
TG_SESSION_STRING=
# Fallback (file-based): only used if TG_SESSION_STRING is empty.
# Requires mounting ./data/session as a volume.
TG_SESSION_PATH=/data/session/parser.session
# Postgres
POSTGRES_USER=parser
POSTGRES_PASSWORD=parser
POSTGRES_DB=parser
POSTGRES_HOST=db
POSTGRES_PORT=5432
# Polling
POLL_INTERVAL_SECONDS=60
POLL_HISTORY_LIMIT=50
# API
API_HOST=0.0.0.0
API_PORT=8000
# Media (downloaded photos / small videos / docs from parsed messages)
MEDIA_DIR=/data/media
MEDIA_MAX_BYTES=20971520
# Local LLM (Ollama) — runs Qwen 2.5 7B Q4 on CPU. Set LLM_ENABLED=false to disable.
LLM_ENABLED=true
LLM_BASE_URL=http://ollama:11434
LLM_MODEL=qwen2.5:7b-instruct-q4_K_M
LLM_TIMEOUT_SECONDS=120
LLM_MIN_TEXT_LENGTH=20
# How often the background classifier wakes up and how many messages it
# processes per tick. With 5/20s ≈ 900 messages/hour at ~3-6s per call.
LLM_CLASSIFY_INTERVAL_SECONDS=20
LLM_CLASSIFY_BATCH_SIZE=5
# Admin allowlist for /auth.html, /docs, /openapi.json, /redoc and the
# /api/v1/auth/* endpoints. Comma-separated list of client IPs.
# Empty = no restriction (everyone is admin) — convenient for local dev.
# Example: ADMIN_ALLOWED_IPS=89.110.109.221,127.0.0.1
ADMIN_ALLOWED_IPS=
# Honor X-Forwarded-For / X-Real-IP from a reverse proxy (Docker port-
# forward, nginx, traefik) when resolving the client IP for the allowlist.
TRUST_PROXY_HEADERS=true