feat: Docker, health check, schema migrations y webhook opt-in

- migrations/001_initial_schema.sql: DDL idempotente con CREATE TABLE/INDEX IF NOT EXISTS
- database.py: run_migrations() aplica .sql pendientes en orden; init_db() queda como alias
- health.py: servidor aiohttp en puerto 8080 — GET /health, GET /health/history, POST /webhook
  Watcher loop alerta al admin por Telegram si el poller no actualiza en N horas
- config.py: webhook_url, webhook_secret, health_port, health_alert_hours
- poller.py: on_poll_done callback (conecta con health.record_poll)
- main.py: arranca HealthServer, llama run_migrations, modo webhook opt-in via WEBHOOK_URL
- Dockerfile + docker-compose.yml + .dockerignore
- pyproject.toml: aiohttp>=3.9

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
markosbenitez
2026-05-25 23:31:18 -03:00
parent 537ed6931d
commit 076bc100af
11 changed files with 886 additions and 68 deletions

View File

@@ -57,6 +57,14 @@ class Settings(BaseSettings):
# Código de invitación para registro (vacío = registro abierto)
invite_code: str = ""
# Webhook (vacío = long-polling)
webhook_url: str = "" # ej: https://bot.midominio.com
webhook_secret: str = "" # token secreto para X-Telegram-Bot-Api-Secret-Token
# Health check HTTP
health_port: int = 8080
health_alert_hours: int = 2 # alerta al admin si el poller no actualizó en N horas
# Logging
log_level: str = "INFO"