Back.Serv is a distributed AI task processing system built with Flask and Celery. It provides a robust and scalable backend service for managing and executing various AI-related tasks across multiple servers.
- Distributed Task Processing: Efficiently manage and distribute AI tasks across multiple servers
- Smart Load Balancing: Automatically select the least loaded server for task execution
- Fault Tolerance: Automatic task rescheduling and server failover mechanisms
- Real-time Monitoring: Track task status and server health in real-time
- REST API Interface: Simple and intuitive API endpoints for task submission and management
- Image Creation
- Image Upscaling
- Face Swap
- Video Creation
- Translation Services
- Prompt Services
- Face Detection
The system consists of several key components:
- Flask Backend: Handles HTTP requests and task management
- Celery Workers: Processes distributed tasks asynchronously
- Redis: Message broker for task queue management
- MySQL: Persistent storage for task information and system state
- Health Monitoring: Continuous monitoring of server status and task progress
- Python 3.8+
- Redis Server
- MySQL Server
- Docker (optional)
- Clone the repository:
git clone https://github.com/yourusername/back.serv.git
cd back.serv
- Create and configure environment variables:
cp .env.example .env
# Edit .env with your configuration
- Install dependencies:
pip install -r requirements.txt
-
Configure your database settings in
.env
-
Start the Redis server:
redis-server
- Start the Celery worker:
celery -A celery_tasks worker --loglevel=info
- Run the Flask application:
python back_serv.py
The project includes comprehensive test coverage for both API endpoints and Celery tasks.
- Install test dependencies:
pip install pytest pytest-cov
- Run the test suite:
pytest
- View test coverage report:
pytest --cov=. --cov-report=html
The HTML coverage report will be available in the htmlcov
directory.
tests/test_api.py
: API endpoint teststests/test_celery_tasks.py
: Celery task tests
POST /submit_task
Content-Type: application/json
{
"task_type": "image_creation",
"task_params": {},
"user_id": "user123"
}
GET /query_task/<ticket_id>
POST /cancel_task/<ticket_id>
The system can be configured through environment variables or configuration files. Key configuration options include:
- Database connection settings
- Redis connection settings
- Server health check intervals
- Task timeout thresholds
For detailed configuration options, see the Configuration Guide.
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please:
- Check the documentation
- Search through existing issues
- Create a new issue if needed
- Thanks to all contributors who have helped shape Back.Serv
- Built with Flask, Celery, and other amazing open source projects