-
-
Notifications
You must be signed in to change notification settings - Fork 0
CLI Reference
devstack is a modern Python-based management interface for DevStack Core with comprehensive service profile support. It provides a beautiful CLI experience with colored output, tables, and progress indicators.
Features:
- Service profile management (minimal, standard, full, reference)
- Automatic environment loading from profile .env files
- Beautiful terminal output with Rich library
- Health checks for all services
- Service logs and shell access
- Redis cluster initialization
- Profile listing and validation
- Comprehensive built-in help for all commands
The script includes comprehensive help documentation accessible via standard help commands:
# Main help - shows all commands
./devstack --help
./devstack -h
# Help for specific command - shows all options and examples
./devstack start --help
./devstack logs --help
./devstack stop --help
./devstack vault-show-password --help
# Version information
./devstack --versionEvery command includes:
- ARGUMENTS: Required and optional arguments
- OPTIONS: All available flags and parameters with defaults
- EXAMPLES: Real-world usage examples
- NOTES: Important warnings, tips, and gotchas
Examples of getting help:
# See all available --profile options for start command
./devstack start --help
# Learn about log viewing options (--follow, --tail)
./devstack logs --help
# Understand which services can be queried for passwords
./devstack vault-show-password --help- Python 3.8 or higher (Python 3.14.0 confirmed working)
- pip3 package manager
# Install using uv (recommended)
uv venv
uv pip install -r scripts/requirements.txt
# The wrapper script automatically uses the venv
# No manual activation needed!# If you prefer to manage the venv yourself:
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r scripts/requirements.txt
# Deactivate when done
deactivate
# Note: The wrapper script handles activation automatically# If using Homebrew Python
brew install python@3
# Install dependencies with Homebrew pip
/opt/homebrew/bin/pip3 install click rich PyYAML python-dotenv# Test that all dependencies are available
python3 -c "import click, rich, yaml; print('All dependencies installed!')"
# Test the script
./devstack --version
./devstack --help# Start with standard profile (recommended)
./devstack start --profile standard
# Check status
./devstack status
# Check health
./devstack health
# Stop services
./devstack stopMorning Routine (Start Development Environment):
# Start full development stack
./devstack start --profile standard
# Initialize Redis cluster (first time only)
./devstack redis-cluster-init
# Check all services are healthy
./devstack healthEnd of Day (Stop Everything):
# Stop all services and Colima VM
./devstack stopQuick Check (Status Without Starting):
# Check what's running
./devstack status
# Get Colima IP address
./devstack ipStart Colima VM and Docker services with specified profile(s).
# Start with minimal profile
./devstack start --profile minimal
# Start with standard profile (default)
./devstack start --profile standard
# Start with full profile (all services + observability)
./devstack start --profile full
# Combine multiple profiles
./devstack start --profile standard --profile reference
# Start in foreground (see logs in real-time)
./devstack start --profile minimal --no-detachOptions:
-
--profile, -p: Service profile(s) to start (can specify multiple) -
--detach/--no-detach, -d: Run in background (default: True)
Examples:
# Minimal profile (5 services, 2GB RAM)
./devstack start --profile minimal
# Standard profile with reference apps (15 services)
./devstack start --profile standard --profile reference
# Full profile (18 services, 6GB RAM)
./devstack start --profile fullStop Docker services and optionally Colima VM.
# Stop everything (services + Colima VM)
./devstack stop
# Stop only specific profile services (keeps Colima running)
./devstack stop --profile standard
./devstack stop --profile referenceOptions:
-
--profile, -p: Only stop services from specific profile(s)
Display status of Colima VM and all running services with resource usage.
# Show full status
./devstack statusOutput includes:
- Colima VM status (running/stopped)
- Docker service list with status
- Resource usage (CPU, memory)
Check health status of all running services.
# Check health of all services
./devstack healthOutput shows:
- Service name
- Running status (running/stopped/exited)
- Health check result (healthy/unhealthy/no healthcheck)
Color coding:
- Green: Healthy and running
- Yellow: Running but no healthcheck or starting
- Red: Stopped or unhealthy
View logs for all services or a specific service.
# View all service logs (last 100 lines)
./devstack logs
# View specific service logs
./devstack logs postgres
./devstack logs vault
# Follow logs (like tail -f)
./devstack logs -f redis-1
# Show more lines
./devstack logs --tail 500 postgres
# Follow multiple services (using docker compose directly)
docker compose logs -f postgres vaultOptions:
-
--follow, -f: Follow log output (stream continuously) -
--tail, -n: Number of lines to show (default: 100)
Open an interactive shell in a running container.
# Open shell in PostgreSQL container
./devstack shell postgres
# Open specific shell (bash instead of sh)
./devstack shell vault --shell bash
# Common shell commands after entering:
# PostgreSQL: psql -U $POSTGRES_USER -d $POSTGRES_DB
# Redis: redis-cli -a $REDIS_PASSWORD
# MongoDB: mongosh -u $MONGODB_USER -p $MONGODB_PASSWORDOptions:
-
--shell, -s: Shell to use (default: sh, can use bash if available)
List all available service profiles with details.
# Show all profiles
./devstack profilesOutput includes:
- Profile name
- Number of services
- RAM estimate
- Description and use case
Display Colima VM IP address.
# Get VM IP address
./devstack ipUse cases:
- Accessing services from libvirt VMs
- Configuring network clients
- Debugging network issues
Initialize Redis cluster (required for standard/full profiles).
# Initialize 3-node Redis cluster
./devstack redis-cluster-initWhen to use:
- After first start with
--profile standard - After first start with
--profile full - NOT needed for
--profile minimal(single Redis node)
What it does:
- Creates 3-node Redis cluster
- Distributes 16,384 slots across nodes
- Verifies cluster health
Verify cluster:
# Connect to cluster
redis-cli -c -h localhost -p 6379
# Check cluster nodes
redis-cli -h localhost -p 6379 cluster nodes
# Check cluster info
redis-cli -h localhost -p 6379 cluster info| Profile | Services | RAM | Start Command |
|---|---|---|---|
| minimal | 5 | 2GB | ./devstack start --profile minimal |
| standard | 10 | 4GB | ./devstack start --profile standard |
| full | 18 | 6GB | ./devstack start --profile full |
| reference | +5 | +1GB | ./devstack start --profile standard --profile reference |
Services: vault, postgres, pgbouncer, forgejo, redis-1 (standalone)
Use Cases:
- Git repository hosting
- Simple CRUD application development
- Learning the platform
- CI/CD pipelines (lightweight)
Services: All minimal + mysql, mongodb, redis-2, redis-3, rabbitmq
Use Cases:
- Multi-database application development
- Redis cluster testing (YOUR PRIMARY USE CASE)
- Message queue integration
- Full-featured development
Services: All standard + prometheus, grafana, loki, vector, cadvisor, exporters
Use Cases:
- Performance testing
- Production troubleshooting simulation
- Observability pattern learning
- Load testing with metrics
Services: reference-api, api-first, golang-api, nodejs-api, rust-api
Use Cases:
- Learning API design patterns
- Comparing language implementations
- Testing integration patterns
Note: Must combine with standard or full profile.
The script respects these environment variables:
# Colima profile name
export COLIMA_PROFILE=default
# Colima CPU cores
export COLIMA_CPU=4
# Colima memory in GB
export COLIMA_MEMORY=8
# Colima disk size in GB
export COLIMA_DISK=60The script automatically loads environment variables from:
- Shell environment (highest priority)
configs/profiles/<profile>.env- Root
.envfile - docker-compose.yml defaults (lowest priority)
| Feature | Python Script | Bash Script |
|---|---|---|
| Profile Support | ✅ Native | ❌ No |
| Colored Output | ✅ Rich library | |
| Error Handling | ✅ Excellent | |
| Maintainability | ✅ High | |
| Dependencies | Python + 4 packages | Bash + system tools |
| Cross-platform | ✅ Yes | |
| Progress Indicators | ✅ Spinners | ❌ No |
| Tables | ✅ Formatted |
Current State:
- Bash script (
devstack) - 1,622 lines - Python script (
devstack) - 850 lines
Recommended Approach:
-
Phase 1: Use Python script for profile management
./devstack start --profile standard
-
Phase 2: Use Python script for common operations
./devstack status ./devstack health ./devstack logs <service>
-
Phase 3: Use bash script for advanced operations (until implemented in Python)
./devstack vault-bootstrap ./devstack backup ./devstack forgejo-init
-
Future: Complete Python implementation with all bash script features
Problem: ModuleNotFoundError: No module named 'click'
Solution:
# Install dependencies
pip3 install --user click rich PyYAML python-dotenv
# Or use virtual environment
uv venv
uv pip install -r scripts/requirements.txt
# Wrapper script automatically uses the venvProblem: Permission denied: ./devstack
Solution:
chmod +x devstackProblem: Command not found: colima
Solution:
# Install Colima
brew install colimaProblem: Environment variables from profile not taking effect
Solution:
# Check if profile .env file exists
ls -la configs/profiles/standard.env
# Manually load to debug
set -a
source configs/profiles/standard.env
set +a
env | grep REDISProblem: Error initializing Redis cluster
Solution:
# Check redis containers are running
docker ps | grep redis
# Check if already initialized
redis-cli -h localhost -p 6379 cluster nodes
# Reset if needed (WARNING: destroys data)
docker compose down
docker volume rm devstack-core_redis_1_data devstack-core_redis_2_data devstack-core_redis_3_data
./devstack start --profile standard
./devstack redis-cluster-initCreate a custom profile environment file:
# Create custom profile
cat > configs/profiles/my-custom.env << 'EOF'
# My custom settings
REDIS_MAX_MEMORY=1024mb
POSTGRES_MAX_CONNECTIONS=200
ENABLE_METRICS=true
EOF
# Use custom environment
set -a
source configs/profiles/my-custom.env
set +a
docker compose --profile standard up -dUse the Python script in automation:
#!/bin/bash
# CI/CD example
# Start minimal profile for testing
./devstack start --profile minimal
# Wait for services to be healthy
sleep 30
./devstack health
# Run tests
pytest tests/
# Stop services
./devstack stop# Watch status in real-time
watch -n 5 './devstack status'
# Continuous health monitoring
while true; do
./devstack health
sleep 60
donePlanned features for future versions:
- Vault operations (vault-init, vault-bootstrap, vault-unseal)
- Backup and restore commands
- Forgejo initialization
- Service restart command
- Reset command (destroy and recreate)
- Performance metrics display
- Service dependency visualization
- Configuration validation
- Automated health check scheduling
- Profile switching helper
To add new commands to the Python script:
- Add a new function decorated with
@cli.command() - Use Rich library for beautiful output
- Handle errors gracefully
- Add comprehensive documentation
- Test with all profiles
Example:
@cli.command()
@click.option("--force", is_flag=True, help="Force operation")
def mycommand(force: bool):
"""
Description of my command.
Examples:
./devstack mycommand
./devstack mycommand --force
"""
console.print("[cyan]Running my command...[/cyan]")
# Implementation hereFor help with the Python management script:
- Check this documentation
- Run
./devstack --help - Check command-specific help:
./devstack start --help - Review docs/SERVICE_PROFILES.md
- Open an issue on GitHub
MIT License - See LICENSE file for details