Multi-Rack Configuration
The rack-gateway CLI supports connecting to multiple gateways, making it easy to work with different environments (production, staging, development) from a single machine.
Adding Racks
Section titled “Adding Racks”Each time you run login, you add a new rack configuration:
# Add production rackrack-gateway login production https://gateway-prod.example.com
# Add staging rackrack-gateway login staging https://gateway-staging.example.com
# Add EU production rackrack-gateway login eu-prod https://gateway-eu.example.comThe first argument (production, staging, etc.) is an alias you choose. Use short, memorable names.
Listing Racks
Section titled “Listing Racks”View all configured racks:
rack-gateway racksOutput:
RACK URL USER* production https://gateway-prod.example.com developer@company.com staging https://gateway-staging.example.com developer@company.com eu-prod https://gateway-eu.example.com developer@company.comThe * indicates the current rack.
Switching Racks
Section titled “Switching Racks”Change the default rack:
# Switch to stagingrack-gateway switch staging
# Verifyrack-gateway rack# Output: Current rack: staging (https://gateway-staging.example.com)Per-Command Rack Override
Section titled “Per-Command Rack Override”Use --rack (or -r) to run a single command against a different rack:
# List apps on production while staging is currentrack-gateway apps --rack production
# Deploy to stagingrack-gateway deploy -r staging
# Check logs on EU productionrack-gateway logs -a myapp -r eu-prodThe --rack flag doesn’t change your default; it only affects that one command.
Environment Variable Override
Section titled “Environment Variable Override”Set RACK_GATEWAY_RACK to override the current rack:
# Use staging for all commands in this shellexport RACK_GATEWAY_RACK=stagingrack-gateway apps # Uses staging
# Or for a single commandRACK_GATEWAY_RACK=production rack-gateway appsConfiguration File Structure
Section titled “Configuration File Structure”Your rack configurations are stored in ~/.config/rack-gateway/config.json:
{ "current": "production", "gateways": { "production": { "url": "https://gateway-prod.example.com", "token": "rgw_sess_abc123...", "email": "developer@company.com", "expires_at": "2024-02-15T10:30:00Z", "session_id": 1024, "channel": "cli", "device_id": "8f4c4b8c-...", "device_name": "dev-mbp", "mfa_verified": true }, "staging": { "url": "https://gateway-staging.example.com", "token": "rgw_sess_def456...", "email": "developer@company.com", "expires_at": "2024-02-15T10:30:00Z", "session_id": 2048, "channel": "cli" } }}Removing a Rack
Section titled “Removing a Rack”To remove a rack configuration, log out from it:
# Logout from staging (removes session but keeps config)rack-gateway logout -r stagingTo completely remove a rack, edit the config file directly or log in again with the same alias to replace it.
Updating a Gateway URL
Section titled “Updating a Gateway URL”If a gateway URL changes, simply log in again with the same alias:
# Gateway moved to new URLrack-gateway login production https://new-gateway.example.com# Replaces the old production configurationBest Practices
Section titled “Best Practices”Naming Conventions
Section titled “Naming Conventions”Use consistent, descriptive aliases:
# Good: Clear environment namesrack-gateway login prod https://gateway-prod.example.comrack-gateway login staging https://gateway-staging.example.comrack-gateway login dev https://gateway-dev.example.com
# Good: Region-based for multi-regionrack-gateway login us-prod https://gateway-us.example.comrack-gateway login eu-prod https://gateway-eu.example.com
# Avoid: Ambiguous namesrack-gateway login rack1 https://... # Which environment is this?Shell Aliases for Common Racks
Section titled “Shell Aliases for Common Racks”Create aliases for frequently used rack combinations:
# In ~/.bashrc or ~/.zshrcalias cgp="rack-gateway --rack production"alias cgs="rack-gateway --rack staging"
# Usagecgp apps # Production appscgs deploy # Deploy to stagingCI/CD Configuration
Section titled “CI/CD Configuration”For CI/CD, use API tokens with RACK_GATEWAY_API_TOKEN instead of managing OAuth sessions:
# In your CI environmentexport RACK_GATEWAY_API_TOKEN="rgw_token_..."export RACK_GATEWAY_RACK="production"
rack-gateway deployPrecedence Order
Section titled “Precedence Order”When determining which rack to use:
--rackflag (highest priority)RACK_GATEWAY_RACKenvironment variablecurrentin config file (default)
Troubleshooting
Section titled “Troubleshooting””Rack not found”
Section titled “”Rack not found””Error: rack "production" not foundThe alias doesn’t exist in your config. List available racks:
rack-gateway racks“Session expired” on one rack
Section titled ““Session expired” on one rack”Sessions expire independently per rack. Re-login to the affected rack:
rack-gateway login production https://gateway-prod.example.comDifferent users on different racks
Section titled “Different users on different racks”It’s normal to have different users or roles on different racks. Each rack maintains its own session:
rack-gateway racks# RACK URL USER# * production https://gateway-prod.example.com admin@company.com# staging https://gateway-staging.example.com developer@company.comNext Steps
Section titled “Next Steps”- Commands - Full command reference
- MFA Verification - Step-up authentication