Implement AnonBot integration and monitoring enhancements
- Added AnonBot service to docker-compose with resource limits and environment variables. - Updated Makefile to include commands for AnonBot logs, restart, and dependency checks. - Enhanced Grafana dashboards with AnonBot health metrics and database connection statistics. - Implemented AnonBot status retrieval in the message sender for improved monitoring. - Updated Prometheus configuration to scrape metrics from AnonBot service.
This commit was merged in pull request #2.
This commit is contained in:
35
Makefile
35
Makefile
@@ -1,4 +1,4 @@
|
||||
.PHONY: help build up down logs clean restart status deploy backup restore update clean-monitoring monitoring check-deps check-bot-deps
|
||||
.PHONY: help build up down logs clean restart status deploy backup restore update clean-monitoring monitoring check-deps check-bot-deps check-anonBot-deps
|
||||
|
||||
help: ## Показать справку
|
||||
@echo "🏗️ Production Infrastructure - Доступные команды:"
|
||||
@@ -11,6 +11,7 @@ help: ## Показать справку
|
||||
@echo " Grafana: http://localhost:3000 (admin/admin)"
|
||||
@echo " Server Monitor: http://localhost:9091/health"
|
||||
@echo " Bot Health: http://localhost:8080/health"
|
||||
@echo " AnonBot Health: http://localhost:8081/health"
|
||||
|
||||
build: ## Собрать все контейнеры
|
||||
docker-compose build
|
||||
@@ -36,6 +37,9 @@ logs-grafana: ## Показать логи Grafana
|
||||
logs-bot: ## Показать логи Telegram бота
|
||||
docker-compose logs -f telegram-bot
|
||||
|
||||
logs-anonBot: ## Показать логи AnonBot
|
||||
docker-compose logs -f anon-bot
|
||||
|
||||
restart: ## Перезапустить все сервисы
|
||||
docker-compose down
|
||||
docker-compose build --no-cache
|
||||
@@ -53,12 +57,16 @@ restart-grafana: ## Перезапустить только Grafana
|
||||
restart-bot: ## Перезапустить только Telegram бота
|
||||
docker-compose restart telegram-bot
|
||||
|
||||
restart-anonBot: ## Перезапустить только AnonBot
|
||||
docker-compose restart anon-bot
|
||||
|
||||
status: ## Показать статус контейнеров
|
||||
docker-compose ps
|
||||
|
||||
health: ## Проверить здоровье сервисов
|
||||
@echo "🏥 Checking service health..."
|
||||
@curl -f http://localhost:8080/health || echo "❌ Bot health check failed"
|
||||
@curl -f http://localhost:8081/health || echo "❌ AnonBot health check failed"
|
||||
@curl -f http://localhost:9090/-/healthy || echo "❌ Prometheus health check failed"
|
||||
@curl -f http://localhost:3000/api/health || echo "❌ Grafana health check failed"
|
||||
@curl -f http://localhost:9091/health || echo "❌ Server monitor health check failed"
|
||||
@@ -120,22 +128,26 @@ start: build up ## Собрать и запустить все сервисы
|
||||
@echo "📊 Prometheus: http://localhost:9090"
|
||||
@echo "📈 Grafana: http://localhost:3000 (admin/admin)"
|
||||
@echo "🤖 Bot Health: http://localhost:8080/health"
|
||||
@echo "🔒 AnonBot Health: http://localhost:8081/health"
|
||||
@echo "📡 Server Monitor: http://localhost:9091/health"
|
||||
@echo "📝 Логи: make logs"
|
||||
|
||||
stop: down ## Остановить все сервисы
|
||||
@echo "🛑 Все сервисы остановлены"
|
||||
|
||||
test: check-deps check-bot-deps ## Запустить все тесты в проекте
|
||||
test: check-deps check-bot-deps check-anonBot-deps ## Запустить все тесты в проекте
|
||||
@echo "🧪 Запускаю все тесты в проекте..."
|
||||
@echo "📊 Тесты инфраструктуры..."
|
||||
@python3 -m pytest tests/infra/ -q --tb=no
|
||||
@echo "🤖 Тесты Telegram бота..."
|
||||
@cd bots/telegram-helper-bot && source .venv/bin/activate && python3 -m pytest tests/ -q --tb=no
|
||||
@echo "🔒 Тесты AnonBot..."
|
||||
@cd bots/AnonBot && python3 -m pytest tests/ -q --tb=no
|
||||
@echo "✅ Все тесты завершены!"
|
||||
@echo "📈 Общая статистика:"
|
||||
@echo " - Инфраструктура: $(shell python3 count_tests.py | head -1) тестов"
|
||||
@echo " - Telegram бот: $(shell python3 count_tests.py | head -2 | tail -1) тестов"
|
||||
@echo " - AnonBot: $(shell python3 count_tests.py | head -3 | tail -1) тестов"
|
||||
@echo " - Всего: $(shell python3 count_tests.py | tail -1) тестов"
|
||||
|
||||
test-all: ## Запустить все тесты в одном процессе (только для разработчиков)
|
||||
@@ -152,16 +164,23 @@ test-bot: check-bot-deps ## Запустить тесты Telegram бота
|
||||
@echo "🤖 Запускаю тесты Telegram бота..."
|
||||
@cd bots/telegram-helper-bot && source .venv/bin/activate && python3 -m pytest tests/ -v
|
||||
|
||||
test-coverage: check-deps check-bot-deps ## Запустить все тесты с отчетом о покрытии
|
||||
test-anonBot: check-anonBot-deps ## Запустить тесты AnonBot
|
||||
@echo "🔒 Запускаю тесты AnonBot..."
|
||||
@cd bots/AnonBot && python3 -m pytest tests/ -v
|
||||
|
||||
test-coverage: check-deps check-bot-deps check-anonBot-deps ## Запустить все тесты с отчетом о покрытии
|
||||
@echo "📊 Запускаю все тесты с отчетом о покрытии..."
|
||||
@echo "📈 Покрытие для инфраструктуры..."
|
||||
@python3 -m pytest tests/infra/ --cov=infra --cov-report=term-missing --cov-report=html:htmlcov/infra
|
||||
@echo "🤖 Покрытие для Telegram бота..."
|
||||
@cd bots/telegram-helper-bot && source .venv/bin/activate && python3 -m pytest tests/ --cov=helper_bot --cov-report=term-missing --cov-report=html:htmlcov/bot
|
||||
@echo "🔒 Покрытие для AnonBot..."
|
||||
@cd bots/AnonBot && python3 -m pytest tests/ --cov=. --cov-report=term-missing --cov-report=html:htmlcov/anonbot
|
||||
@echo "📊 Отчеты о покрытии сохранены в htmlcov/"
|
||||
@echo "📈 Общая статистика:"
|
||||
@echo " - Инфраструктура: $(shell python3 count_tests.py | head -1) тестов"
|
||||
@echo " - Telegram бот: $(shell python3 count_tests.py | head -2 | tail -1) тестов"
|
||||
@echo " - AnonBot: $(shell python3 count_tests.py | head -3 | tail -1) тестов"
|
||||
@echo " - Всего: $(shell python3 count_tests.py | tail -1) тестов"
|
||||
|
||||
test-clean: ## Очистить все файлы тестирования и отчеты
|
||||
@@ -173,6 +192,9 @@ test-clean: ## Очистить все файлы тестирования и о
|
||||
@rm -rf bots/telegram-helper-bot/.pytest_cache/
|
||||
@rm -rf bots/telegram-helper-bot/htmlcov/
|
||||
@rm -rf bots/telegram-helper-bot/.coverage
|
||||
@rm -rf bots/AnonBot/.pytest_cache/
|
||||
@rm -rf bots/AnonBot/htmlcov/
|
||||
@rm -rf bots/AnonBot/.coverage
|
||||
@find . -name "*.pyc" -delete 2>/dev/null || true
|
||||
@find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
|
||||
@echo "✅ Файлы тестирования очищены"
|
||||
@@ -187,6 +209,8 @@ check-ports: ## Проверить занятые порты
|
||||
@lsof -i :9091 2>/dev/null || echo " Free"
|
||||
@echo "Port 8080 (Telegram Bot):"
|
||||
@lsof -i :8080 2>/dev/null || echo " Free"
|
||||
@echo "Port 8081 (AnonBot):"
|
||||
@lsof -i :8081 2>/dev/null || echo " Free"
|
||||
|
||||
check-grafana: ## Проверить состояние Grafana
|
||||
@echo "📊 Checking Grafana status..."
|
||||
@@ -202,6 +226,11 @@ check-bot-deps: ## Проверить зависимости Telegram бота
|
||||
@cd bots/telegram-helper-bot && source .venv/bin/activate && python3 -c "import aiogram, aiosqlite, pytest" 2>/dev/null || (echo "❌ Отсутствуют зависимости бота. Установите: cd bots/telegram-helper-bot && source .venv/bin/activate && pip install -r requirements.txt" && exit 1)
|
||||
@echo "✅ Зависимости Telegram бота установлены"
|
||||
|
||||
check-anonBot-deps: ## Проверить зависимости AnonBot
|
||||
@echo "🔍 Проверяю зависимости AnonBot..."
|
||||
@cd bots/AnonBot && python3 -c "import aiogram, aiosqlite, pytest, loguru, pydantic" 2>/dev/null || (echo "❌ Отсутствуют зависимости AnonBot. Установите: cd bots/AnonBot && pip install -r requirements.txt" && exit 1)
|
||||
@echo "✅ Зависимости AnonBot установлены"
|
||||
|
||||
logs-tail: ## Показать последние логи всех сервисов
|
||||
@echo "📝 Recent logs from all services:"
|
||||
@docker-compose logs --tail=50
|
||||
|
||||
Reference in New Issue
Block a user