6c8c05b13b
- Buffer locale samples[] per aggiornamenti real-time - Poll /api/status ogni 10 secondi - Aggiunge nuovi campioni senza ricaricare history - Aggiunge AGENTS.md per istruzioni agenti OpenCode - Aggiunge team agenti in .opencode/agents/
1.5 KiB
1.5 KiB
AGENTS.md
Quick Commands
pytest -q # Run all tests
python app.py # Start server (requires valid .env)
Testing
- Tests use
config_overrideincreate_app()to mock settings and skip the collector thread (start_collector=False). - No database connection required for tests—SQLite uses temp directories.
- Test files:
tests/test_api.pywith 3 test functions.
Required Env Vars
| Variable | Purpose |
|---|---|
SUPABASE_DB_HOST |
Connection pooler hostname |
SUPABASE_DB_PORT |
Pooler port (typically 6543) |
SUPABASE_DB_NAME |
Database name |
SUPABASE_DB_USER |
User in format postgres.<project-ref> |
SUPABASE_DB_PASSWORD |
Password |
App Architecture
- Entry:
app.pyexportscreate_app()andapp(FastAPI instance). - Config:
load_config()validates required vars, returnsSettingsdataclass. - Storage:
RRDStoreclass manages SQLite circular buffer (auto-prunes based onmax_samples). - Ping:
run_ping()executes keep-alive query, returns(success, latency_ms, error_message). - Collector:
collector_loop()runs in daemon thread, interval fromPING_INTERVAL_MINUTES.
API Endpoints
GET /— Dashboard (SmokePing-style)GET /api/status— Latest sampleGET /api/history?hours=48— Sample history (max 48h)GET /docs— Swagger UIGET /openapi.json— OpenAPI schema
Docker
docker build -t supabase-pinger .
docker run -d --env-file .env -p 8080:8080 --restart unless-stopped supabase-pinger