Transform your idle devices into a unified AI work cluster! A distributed system based on TCP socket communication that organizes old phones, tablets, and laptops into a powerful computing cluster.
Retire-Cluster is an innovative solution for repurposing idle devices, designed for users with multiple unused devices. It transforms "retired" phones, tablets, and old laptops into a unified work cluster, bringing new life to these devices.
The system supports automatic device discovery, real-time status monitoring, intelligent task scheduling, and provides a natural language interface for cluster management.
- β»οΈ Device Repurposing: Give new life to old phones, tablets, and laptops
- π€ Intelligent Scheduling: Automatically select the best execution node based on device capabilities
- π Real-time Monitoring: Heartbeat mechanism ensures real-time status updates with automatic failure detection
- π§ Auto-Discovery: Self-aware system that automatically collects and reports hardware/software information
- π Dynamic Scaling: Support hot-plugging of devices without service restart
- π‘οΈ Fault Tolerance: Automatic failure detection and task redistribution
- π Cross-Platform: Support for Windows, Linux, macOS, and Android (Termux)
- β‘ Task Execution: Distributed task execution with priority queuing and requirement matching
- π REST API: Comprehensive HTTP API for programmatic cluster management
- π Security: API authentication, rate limiting, and input validation
- π Integrations: Support for Temporal, Celery, and custom framework integrations
- π¦ Easy Installation: Single pip install with automatic configuration
βββββββββββββββββββββββ βββββββββββββββββββββββ
β Main Node β β Worker Node β
β βββββββββββ€ β
β βββββββββββββββββββ β β βββββββββββββββββββ β
β βDevice Registry β β β βDevice Profiler β β
β βTask Scheduler β β β βSystem Monitor β β
β βHeartbeat Monitorβ β β βTask Executor β β
β βββββββββββββββββββ β β βββββββββββββββββββ β
βββββββββββββββββββββββ βββββββββββββββββββββββ
TCP Socket TCP Socket
- Main Node: Cluster coordinator and management center
- Worker Node: Task execution units supporting various platforms
- Storage Node: Data storage and file services (planned)
- Python 3.10+
- Network connectivity (all devices on the same network)
- Optional: psutil for enhanced system monitoring
# Basic installation
pip install retire-cluster
# With REST API support
pip install retire-cluster[api]
# With framework integrations
pip install retire-cluster[integrations]
# Full installation with all features
pip install retire-cluster[all]
# Or install from source
git clone https://github.com/4ier/retire-cluster.git
cd retire-cluster
pip install .[all]# Start main node with default settings
retire-cluster-main
# Start with custom port and data directory
retire-cluster-main --port 9090 --data-dir /opt/retire-cluster
# Initialize configuration file
retire-cluster-main --init-config# Join cluster with auto-detection
retire-cluster-worker --join 192.168.1.100
# Join with custom device ID and role
retire-cluster-worker --join 192.168.1.100:8080 --device-id my-laptop --role compute
# Test connection only
retire-cluster-worker --test 192.168.1.100# View cluster overview
retire-cluster-status 192.168.1.100
# List all devices
retire-cluster-status 192.168.1.100 --devices
# View specific device details
retire-cluster-status 192.168.1.100 --device worker-001
# Filter devices by role
retire-cluster-status 192.168.1.100 --devices --role mobile
# Output in JSON format
retire-cluster-status 192.168.1.100 --json# Start API server with default settings
retire-cluster-api
# Start with authentication and custom port
retire-cluster-api --port 8081 --auth --api-key your-secret-key
# Connect to specific cluster node
retire-cluster-api --cluster-host 192.168.1.100 --cluster-port 8080# Check API health
curl http://localhost:8081/health
# Get cluster status
curl http://localhost:8081/api/v1/cluster/status
# List devices
curl http://localhost:8081/api/v1/devices
# Submit a task
curl -X POST http://localhost:8081/api/v1/tasks \
-H "Content-Type: application/json" \
-d '{"task_type": "echo", "payload": {"message": "Hello API!"}}'
# Check task status
curl http://localhost:8081/api/v1/tasks/{task_id}/status# Submit tasks programmatically
from retire_cluster.tasks import Task, TaskRequirements, TaskPriority
# Simple task
task = Task(
task_type="echo",
payload={"message": "Hello World!"},
priority=TaskPriority.NORMAL
)
# Task with specific requirements
compute_task = Task(
task_type="python_eval",
payload={"expression": "sum(range(1000000))"},
requirements=TaskRequirements(
min_cpu_cores=4,
min_memory_gb=8,
required_platform="linux"
)
)
# Submit to scheduler
task_id = scheduler.submit_task(task)- Architecture Guide - Complete system architecture and design
- Deployment Guide - Comprehensive deployment instructions
- Web Interface Design - Terminal-style web dashboard
- CLI Interface Specification - Command reference
- AI Integration Guide - AI-friendly interface patterns
# Using Docker (Recommended for production)
git clone https://github.com/yourusername/retire-cluster.git
cd retire-cluster
cp .env.example .env
./docker/deploy.sh
# Or run natively
python -m retire_cluster.main_node --host 0.0.0.0 --port 8080# Download worker script
curl -O https://raw.githubusercontent.com/yourusername/retire-cluster/main/examples/simple_worker_client.py
# Run worker
python simple_worker_client.py \
--device-id my-device \
--main-host 192.168.1.100 \
--role compute# Open in browser
open http://your-main-node:5000
# CLI-friendly access (AI/automation)
curl http://your-main-node:5000/text/devices
curl http://your-main-node:5000/api/v1/cluster/status# Install Termux from F-Droid
pkg update && pkg install python
pip install psutil requests
# Run worker
python simple_worker_client.py --device-id android-$(hostname) --role mobile --main-host 192.168.1.100# Install dependencies
sudo apt update && sudo apt install python3 python3-pip -y
pip3 install psutil requests
# Run worker
python3 simple_worker_client.py --device-id rpi-$(hostname) --role compute --main-host 192.168.1.100# Synology/QNAP NAS
ssh admin@nas-ip
cd /volume1/docker # or /share/Container for QNAP
git clone https://github.com/yourusername/retire-cluster.git
cd retire-cluster
./docker/deploy.sh --data-path /volume1/docker/retire-clusterDefine custom roles for specialized devices:
# In worker configuration
config.role = "gpu-compute" # For GPU-enabled devices
config.role = "storage" # For NAS or storage servers
config.role = "mobile" # For mobile devicesThe system automatically detects device capabilities:
- Computational: CPU cores, GPU availability
- Storage: Available disk space
- Services: Network services, automation capabilities
Monitor cluster status in real-time:
# Get cluster statistics
stats = registry.get_cluster_stats()
print(f"Online devices: {stats['online_devices']}")
print(f"Total resources: {stats['total_resources']}")The system uses JSON-based messaging over TCP sockets:
{
"message_type": "register|heartbeat|status",
"sender_id": "device-id",
"data": {
// Message-specific data
}
}- register: Device registration with capabilities
- heartbeat: Periodic status updates with metrics
- status: Query cluster or device status
- task_assign: Assign task to device (planned)
- task_result: Return task execution results (planned)
We welcome contributions! Please see CONTRIBUTING.md for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by distributed computing projects
- Built with Python's asyncio and socket libraries
- Special thanks to the open-source community
- GitHub Issues: Report bugs or request features
- Discussions: Join the conversation
- Basic device management
- TCP socket communication
- Heartbeat monitoring
- Cross-platform support
- CLI package-based installation
- Device profiling and auto-detection
- Simple worker deployment
- Task execution framework
- Intelligent task scheduling and queue management
- Built-in task types (echo, sleep, system_info, etc.)
- Task requirements and device capability matching
- REST API with comprehensive endpoints
- API authentication and security middleware
- Complete API documentation and examples
- Web dashboard with terminal-style interface
- Docker deployment support with automated scripts
- CLI-style web interface with xterm.js terminal
- Multi-format APIs (JSON, CSV, TSV, plain text)
- Real-time streaming with Server-Sent Events
- AI-friendly interface patterns
- Docker containerization with health monitoring
- Automated backup and recovery scripts
- NAS deployment guides (Synology, QNAP)
- Enhanced security with authentication and SSL/TLS
- Performance monitoring and metrics dashboard
- Advanced task scheduling algorithms
- Plugin system for custom task types
- Configuration management UI
- Multi-language worker support (Node.js, Go)
- Temporal workflow integration support
- Celery task queue integration
- HTTP bridge for external frameworks
- Basic monitoring integration (Prometheus metrics)
Give your idle devices a new purpose! π