QuantumAlpha provides command-line tools for deployment, testing, monitoring, and maintenance operations.
- Setup Scripts
- Service Management
- Testing Commands
- Deployment Commands
- Database Operations
- Monitoring Scripts
Initialize the development environment.
| Command | Arguments | Description | Example |
|---|---|---|---|
setup_env.sh |
-e, --env <ENV> |
Setup environment (dev/staging/prod) | ./scripts/setup_env.sh --env dev |
-h, --help |
Show help message | ./scripts/setup_env.sh --help |
Full Example:
# Setup development environment
./scripts/setup_env.sh --env dev
# What it does:
# - Checks Python 3.10+, Docker, Docker Compose
# - Creates Python virtual environment
# - Installs backend dependencies
# - Installs frontend dependencies (if Node.js available)
# - Creates .env file from template
# - Validates configurationEnvironment Options:
dev- Development environment with debug loggingstaging- Staging environment with test dataprod- Production environment with strict security
Start all services in production mode.
| Command | Arguments | Description | Example |
|---|---|---|---|
start.sh |
None | Start all services with Docker Compose | ./scripts/start.sh |
./scripts/start.sh
# Starts:
# - PostgreSQL (TimescaleDB)
# - Redis
# - Kafka + Zookeeper
# - InfluxDB
# - MongoDB
# - All microservices
# - Web dashboardStart services in development mode with hot-reload.
| Command | Arguments | Description | Example |
|---|---|---|---|
start_dev.sh |
None | Start development servers | ./scripts/start_dev.sh |
--service <SERVICE> |
Start specific service | ./scripts/start_dev.sh --service ai_engine |
|
--port <PORT> |
Override default port | ./scripts/start_dev.sh --service ai_engine --port 9000 |
# Start all services in dev mode
./scripts/start_dev.sh
# Start specific service
./scripts/start_dev.sh --service ai_engine --port 8082
# What it does:
# - Starts services with debug mode enabled
# - Enables hot-reload for code changes
# - Verbose logging to console
# - Mock data for testingStart individual services with custom configuration.
| Command | Arguments | Description | Example |
|---|---|---|---|
start_service.sh |
--service <NAME> |
Service name (required) | ./scripts/start_service.sh --service data_service |
--port <PORT> |
Port number | --port 8081 |
|
--env <ENV> |
Environment | --env prod |
|
--workers <N> |
Number of workers | --workers 4 |
# Start data service on custom port
./scripts/start_service.sh \
--service data_service \
--port 8081 \
--env prod \
--workers 4Stop running services.
| Command | Arguments | Description | Example |
|---|---|---|---|
stop.sh |
None | Stop all services | ./scripts/stop.sh |
stop_services.sh |
--service <NAME> |
Stop specific service | ./scripts/stop_services.sh --service ai_engine |
--all |
Stop all services | ./scripts/stop_services.sh --all |
# Stop all services
./scripts/stop.sh
# Stop specific service
./scripts/stop_services.sh --service data_serviceExecute test suites.
| Command | Arguments | Description | Example |
|---|---|---|---|
run_tests.sh |
None | Run all tests | ./scripts/run_tests.sh |
--unit |
Run unit tests only | ./scripts/run_tests.sh --unit |
|
--integration |
Run integration tests | ./scripts/run_tests.sh --integration |
|
--system |
Run system tests | ./scripts/run_tests.sh --system |
|
--coverage |
Generate coverage report | ./scripts/run_tests.sh --coverage |
|
--verbose |
Verbose output | ./scripts/run_tests.sh --verbose |
# Run all tests
./scripts/run_tests.sh
# Run specific test suite with coverage
./scripts/run_tests.sh --unit --coverage
# Run tests with verbose output
./scripts/run_tests.sh --integration --verboseTest Output:
Running unit tests...
============================= test session starts ==============================
collected 145 items
tests/unit/ai_engine/test_model_manager.py ........ [ 5%]
tests/unit/risk_service/test_risk_calculator.py ..... [ 8%]
...
========================= 145 passed in 45.23s ==========================
Coverage: 78%
Run code quality checks.
| Command | Arguments | Description | Example |
|---|---|---|---|
lint.sh |
None | Run all linters | ./scripts/lint.sh |
--fix |
Auto-fix issues | ./scripts/lint.sh --fix |
|
--backend |
Lint Python code only | ./scripts/lint.sh --backend |
|
--frontend |
Lint JS/TS code only | ./scripts/lint.sh --frontend |
# Run all linters
./scripts/lint.sh
# Auto-fix Python code
./scripts/lint.sh --backend --fix
# Lint tools used:
# - flake8 (Python)
# - black (Python formatter)
# - mypy (Python type checking)
# - ESLint (JavaScript/TypeScript)
# - Prettier (JS/TS formatter)Deploy to remote environments.
| Command | Arguments | Description | Example |
|---|---|---|---|
deploy.sh |
--env <ENV> |
Target environment (staging/prod) | ./scripts/deploy.sh --env staging |
--version <TAG> |
Version tag to deploy | --version v1.2.0 |
|
--skip-tests |
Skip pre-deployment tests | --skip-tests |
|
--rollback |
Rollback to previous version | --rollback |
# Deploy to staging
./scripts/deploy.sh --env staging
# Deploy specific version to production
./scripts/deploy.sh --env prod --version v1.2.0
# Rollback production deployment
./scripts/deploy.sh --env prod --rollbackDeployment Steps:
- Validate environment configuration
- Run tests (unless
--skip-tests) - Build Docker images
- Push images to registry
- Update infrastructure (Terraform)
- Deploy new containers
- Run smoke tests
- Update monitoring alerts
Deploy to Kubernetes clusters.
| Command | Arguments | Description | Example |
|---|---|---|---|
k8s_deploy.sh |
--cluster <NAME> |
Kubernetes cluster name | ./scripts/k8s_deploy.sh --cluster prod-cluster |
--namespace <NS> |
Kubernetes namespace | --namespace quantumalpha |
|
--context <CTX> |
kubectl context | --context gke_project_us-central1_cluster |
|
--dry-run |
Validate without applying | --dry-run |
# Deploy to production cluster
./scripts/k8s_deploy.sh \
--cluster prod-cluster \
--namespace quantumalpha \
--context gke_quantumalpha_us-central1_prod
# Dry run deployment
./scripts/k8s_deploy.sh --cluster staging-cluster --dry-runInitialize database schema.
| Command | Arguments | Description | Example |
|---|---|---|---|
python setup_db.py |
--env <ENV> |
Environment | python scripts/setup_db.py --env dev |
--drop |
Drop existing tables | --drop |
|
--seed |
Load seed data | --seed |
# Initialize database
python scripts/setup_db.py --env dev
# Reset database with seed data
python scripts/setup_db.py --env dev --drop --seedBackup databases.
| Command | Arguments | Description | Example |
|---|---|---|---|
backup.sh |
None | Backup all databases | ./scripts/backup.sh |
--db <NAME> |
Backup specific database | --db postgres |
|
--output <PATH> |
Output directory | --output /backups |
|
--compress |
Compress backup | --compress |
# Backup all databases
./scripts/backup.sh
# Backup PostgreSQL with compression
./scripts/backup.sh --db postgres --compress --output /backups
# Creates:
# /backups/postgres_20231215_103000.sql.gz
# /backups/redis_20231215_103000.rdb
# /backups/influxdb_20231215_103000.tar.gzRestore database backups.
| Command | Arguments | Description | Example |
|---|---|---|---|
restore.sh |
--backup <FILE> |
Backup file to restore | ./scripts/restore.sh --backup backup.sql.gz |
--db <NAME> |
Database name | --db postgres |
|
--force |
Skip confirmation | --force |
# Restore PostgreSQL backup
./scripts/restore.sh \
--backup /backups/postgres_20231215_103000.sql.gz \
--db postgres
# Force restore without confirmation
./scripts/restore.sh --backup backup.sql.gz --forceSetup monitoring infrastructure.
| Command | Arguments | Description | Example |
|---|---|---|---|
monitor_setup.sh |
None | Setup Prometheus + Grafana | ./scripts/monitor_setup.sh |
--prometheus-only |
Setup Prometheus only | --prometheus-only |
|
--grafana-only |
Setup Grafana only | --grafana-only |
|
--port <PORT> |
Custom Prometheus port | --port 9090 |
# Setup complete monitoring stack
./scripts/monitor_setup.sh
# Setup Prometheus only on custom port
./scripts/monitor_setup.sh --prometheus-only --port 9091What it does:
- Installs Prometheus
- Configures service discovery
- Sets up alerting rules
- Installs Grafana
- Imports pre-built dashboards
- Configures data sources
- Sets up alert notifications
For direct Docker Compose usage:
# Start services
docker-compose up -d
# Start specific services
docker-compose up -d postgres redis kafka
# View logs
docker-compose logs -f
docker-compose logs -f ai_engine
# Restart service
docker-compose restart data_service
# Stop services
docker-compose down
# Stop and remove volumes
docker-compose down -v
# Rebuild images
docker-compose build --no-cache
# Scale services
docker-compose up -d --scale ai_engine=3
# Check status
docker-compose ps
# Execute command in container
docker-compose exec ai_engine python manage.py shellFor running services directly with Python:
# Activate virtual environment
source venv/bin/activate
# Start AI Engine
cd backend
python ai_engine/app.py
# Start with gunicorn (production)
gunicorn -w 4 -b 0.0.0.0:8082 ai_engine.app:app
# Start with custom config
FLASK_ENV=production python ai_engine/app.py
# Run with debugger
FLASK_DEBUG=1 python ai_engine/app.pyCommon environment variables for CLI scripts:
# Override default ports
export DATA_SERVICE_PORT=8081
export AI_ENGINE_PORT=8082
export RISK_SERVICE_PORT=8083
export EXECUTION_SERVICE_PORT=8084
# Set environment
export FLASK_ENV=development
export LOG_LEVEL=DEBUG
# Database
export DB_HOST=localhost
export DB_PORT=5432
# Use in scripts
./scripts/start_dev.sh# Find process using port
lsof -i :8080
sudo netstat -tulpn | grep 8080
# Kill process
kill -9 <PID>
# Or start on different port
./scripts/start_service.sh --service ai_engine --port 9000# Make scripts executable
chmod +x scripts/*.sh
# Run with sudo if needed
sudo ./scripts/setup_env.sh# Start Docker
sudo systemctl start docker # Linux
open -a Docker # macOS
# Check Docker status
docker info| Task | Command |
|---|---|
| Setup environment | ./scripts/setup_env.sh |
| Start all services | ./scripts/start.sh |
| Start dev mode | ./scripts/start_dev.sh |
| Run tests | ./scripts/run_tests.sh |
| Check code quality | ./scripts/lint.sh --fix |
| Backup database | ./scripts/backup.sh |
| Deploy to staging | ./scripts/deploy.sh --env staging |
| View logs | docker-compose logs -f |
| Stop services | ./scripts/stop.sh |
See Also:
- USAGE.md - Python library usage
- API.md - API endpoints
- TROUBLESHOOTING.md - Common issues