Some checks failed
- Package Publishing: PyPI and npm package setup and automation - Deployment Automation: systemd services, one-command deploy, SSL setup - Security & Audit: third-party audit, Circom review, ZK proof audit, token economy review - Distribution & Binaries: cross-platform builds, vLLM integration, GitHub Releases, code signing - Documentation: API reference, deployment guide, security best practices, video tutorials - Quality Assurance: E2E testing, load testing, cross-platform validation, disaster recovery, security testing Each workflow includes: - Prerequisites - Detailed step-by-step instructions - Verification checklists - Troubleshooting guidance - Related file references
5.3 KiB
5.3 KiB
description
| description |
|---|
| Deployment Automation Workflow for AITBC Services |
Deployment Automation Workflow
This workflow covers the automation of AITBC service deployment with one-command setup.
Prerequisites
- Linux server with systemd support
- Python 3.13+ installed
- Docker and Docker Compose (optional, for containerized services)
- SSH access to target servers
- Domain name configured (for SSL certificates)
Steps
1. System Service One-Command Setup (systemd)
-
Create systemd service templates
- Create service files for each AITBC component:
aitbc-coordinator-api.serviceaitbc-blockchain-node.serviceaitbc-wallet.serviceaitbc-gpu-miner.serviceaitbc-agent-daemon.service
- Store templates in
systemd/directory - Include proper dependencies and restart policies
- Create service files for each AITBC component:
-
Configure service dependencies
- Define startup order (blockchain → coordinator → wallet → miners)
- Add
After=andRequires=directives - Configure automatic restart on failure
- Set resource limits (CPU, memory)
-
Create service management script
- Script:
scripts/service/manage-services.sh - Commands: start, stop, restart, status, logs
- Handle multiple services with dependency ordering
- Include health checks before starting dependent services
- Script:
2. One-Command Deployment Script (./deploy.sh)
-
Create main deployment script
- Script:
scripts/deploy/deploy.sh - Make executable:
chmod +x scripts/deploy/deploy.sh - Include error handling and rollback capability
- Script:
-
Deployment script functionality
# Main deployment steps - Check system prerequisites - Install dependencies (Python, system packages) - Clone or update repository - Create virtual environment - Install Python dependencies - Configure environment variables - Initialize databases - Generate SSL certificates - Start systemd services - Run health checks - Display deployment status -
Add rollback capability
- Backup previous deployment
- Rollback on failure
- Restore previous configuration
- Restart services with old version
3. Environment Configuration Templates (.env.example)
-
Create .env.example template
- File:
.env.exampleat project root - Include all required environment variables
- Add comments explaining each variable
- Group variables by service/component
- File:
-
Template sections
# Blockchain Configuration CHAIN_ID=ait-mainnet BLOCKCHAIN_RPC_PORT=8006 # Coordinator API COORDINATOR_API_PORT=8001 COORDINATOR_API_HOST=0.0.0.0 DATABASE_URL=postgresql://user:pass@localhost/aitbc # Wallet WALLET_DAEMON_PORT=8000 WALLET_PASSWORD=your_secure_password # GPU Miner MINER_API_KEY=your_api_key MINER_GPU_DEVICE=0 -
Create validation script
- Script:
scripts/deploy/validate-env.sh - Check all required variables are set
- Validate variable formats (ports, URLs)
- Test database connectivity
- Verify API keys are valid format
- Script:
4. Service Health Checks and Monitoring
-
Create health check endpoints
- Add
/health/liveendpoint to each service - Add
/health/readyendpoint for readiness checks - Return JSON with service status and dependencies
- Add
-
Create monitoring script
- Script:
scripts/monitoring/health-check.sh - Check all service health endpoints
- Monitor service resource usage (CPU, memory, disk)
- Alert on service failures
- Log health check results
- Script:
-
Integrate with systemd
- Add
ExecStartPost=for health checks - Configure restart on health check failure
- Use systemd notify for service readiness
- Add
5. Automatic SSL Certificate Generation (Let's Encrypt)
-
Install certbot
- Script:
scripts/deploy/install-certbot.sh - Install certbot and certbot-auto
- Configure webroot authentication
- Set up auto-renewal cron job
- Script:
-
Create certificate generation script
- Script:
scripts/deploy/generate-ssl.sh - Request certificate for domain
- Configure nginx with SSL certificates
- Set up certificate auto-renewal
- Handle certificate renewal hooks
- Script:
-
Configure nginx reverse proxy
- SSL termination at nginx
- Redirect HTTP to HTTPS
- Configure modern TLS settings (TLS 1.3)
- Add security headers (HSTS, X-Frame-Options)
Verification
- All systemd services start in correct order
- Deployment script completes successfully
- .env.example template is complete
- Health checks pass for all services
- SSL certificates are generated and renewed
- Services are accessible via HTTPS
- Rollback capability tested
Troubleshooting
- Service fails to start: Check logs with
journalctl -u service-name, verify dependencies - Deployment script fails: Check error logs, verify prerequisites, test individual steps
- Health checks fail: Verify service is running, check endpoint configuration
- SSL certificate fails: Check domain DNS, verify port 80 is open, check certbot logs
- Environment validation fails: Verify all required variables are set, check formats
Related Files
systemd/*.servicescripts/deploy/deploy.sh.env.examplescripts/deploy/validate-env.shscripts/monitoring/health-check.shscripts/deploy/generate-ssl.shnginx/nginx.conf