Files
proxy-scraper/Makefile
LeoMortari 23c8133f3d init repo
2025-11-21 18:23:19 -03:00

82 lines
2.2 KiB
Makefile

# Makefile for Proxy Scraping Service
# Provides convenient commands for common operations
.PHONY: help build up down logs restart clean test immediate admin
help:
@echo "Proxy Scraping Service - Available Commands:"
@echo ""
@echo " make build - Build Docker images"
@echo " make up - Start all services"
@echo " make down - Stop all services"
@echo " make logs - View logs (real-time)"
@echo " make restart - Restart all services"
@echo " make clean - Stop services and remove volumes"
@echo " make immediate - Run scraping job immediately"
@echo " make admin - Start services with pgAdmin"
@echo " make stats - Show database statistics"
@echo " make shell - Open shell in scraper container"
@echo ""
build:
docker-compose build --no-cache
up:
docker-compose up -d
@echo "Services started. View logs with: make logs"
down:
docker-compose down
logs:
docker-compose logs -f proxy-scraper
restart:
docker-compose restart
clean:
docker-compose down -v
@echo "All services stopped and volumes removed"
immediate:
docker-compose exec proxy-scraper python src/main.py --immediate
admin:
docker-compose --profile admin up -d
@echo "Services started with pgAdmin at http://localhost:5050"
stats:
@docker-compose exec postgres psql -U postgres -d proxies -c "\
SELECT \
COUNT(*) as total_proxies, \
COUNT(*) FILTER (WHERE is_active = TRUE) as active_proxies, \
COUNT(*) FILTER (WHERE is_anonymous = TRUE) as anonymous_proxies, \
COUNT(DISTINCT protocol) as unique_protocols, \
COUNT(DISTINCT country_code) as unique_countries, \
ROUND(AVG(response_time_ms)) as avg_response_time_ms \
FROM proxies;"
shell:
docker-compose exec proxy-scraper /bin/bash
# Setup commands
setup:
@if [ ! -f .env ]; then \
cp .env.example .env; \
echo ".env file created. Please edit it with your credentials."; \
else \
echo ".env file already exists"; \
fi
# Development commands
dev-install:
python -m venv venv
. venv/bin/activate && pip install -r requirements.txt
dev-run:
@if [ ! -f .env ]; then \
echo "Error: .env file not found. Run 'make setup' first"; \
exit 1; \
fi
. venv/bin/activate && export POSTGRES_HOST=localhost && python src/main.py --immediate