refactor: full async, rate limit backoff, graceful shutdown, health endpoint

- Switch from requests to httpx.AsyncClient (full async HTTP)
- Add _request() with exponential backoff on 429/401
- Cache followees with 5-min TTL to reduce API calls
- Remove dead code (_get_all_stories, instagram_password, session_file)
- Graceful shutdown via asyncio.Event + SIGTERM/SIGINT handlers
- Add /health command with connection status
- Stream media downloads with httpx + aiofiles
- Track story expiring_at for smart cleanup
- Sanitize .env.example (remove real tokens)
This commit is contained in:
2026-06-17 16:03:47 +07:00
parent da64550426
commit 330e48beaa
6 changed files with 213 additions and 160 deletions

View File

@@ -74,6 +74,7 @@ docker compose up -d
| `/start` | Информация о боте |
| `/check` | Проверить обновления сейчас |
| `/status` | Статистика базы |
| `/health` | Статус подключений |
| `/stop` | Остановить мониторинг |
## API