A task queue system built with FastAPI, Redis, and a simple HTML dashboard to monitor live tasks, handle failures, view logs, and test real-world DevOps architecture.
- β Submit tasks via FastAPI
- π· Process background tasks with retry logic
- β Auto-handles task failures and retries
- π Admin dashboard displays:
- Live and completed tasks
- Failed tasks with error info
- π Task logs viewable directly from the UI
- π All logs are saved to
logs/task_queue.log
.
βββ main.py # FastAPI server with API routes
βββ redis_queue.py # Task enqueue logic
βββ worker.py # Background task processor
βββ logger.py # Centralized logger setup
βββ templates/
βββ dashboard.html # HTML dashboard (Admin UI)
βββ logs/
β βββ task_queue.log # Log file (auto-created)
βββ requirements.txt # Python dependencies
βββ Dockerfile
βββ docker-compose.yml # Multi-container Docker setup
Make sure Redis is running on localhost:6379
.
# Step 1: Build Docker image
docker build -t smart-queue .
# Step 2: Run the container
docker run -p 8000:8000 smart-queue
Visit the app at: http://localhost:8000
π₯ Submit Task Example (API)
curl -X POST http://localhost:8000/submit \
-H "Content-Type: application/json" \
-d '{"task_name": "test_api", "data": {"key": "value"}}'
π» Admin Dashboard
Accessible at: http://localhost:8000/admin
Includes:
π Live task list with real-time status
- Uses WebSocket (`/ws/tasks`) to show live task status updates instantly
- Built with FastAPI + Uvicorn + Vanilla JS
β
Completed task results
β Failed task error messages
π Log viewer (reads last 50 lines from task_queue.log)
π§ͺ API Endpoints
Method Endpoint Description
POST /submit Submit a new task
GET /admin View the admin dashboard (UI)
GET /tasks Get all pending/processing tasks
GET /tasks/completed Get completed tasks
GET /logs View last 50 lines from log
π Retry Logic
Max retries per task: 2
Failed tasks are automatically retried
Redis tracks status:
queued
processing
completed
failed
π³ Coming Soon
β
Dockerized backend (multi-service with Redis)
π GitHub Actions CI/CD
βοΈ React frontend for the dashboard
βοΈ Author
~ Ashwin Bagul
Built with β€οΈ as a real-world DevOps & distributed task system showcase.
---