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:
Configured racks:* production staging eu-prodThe * marks the current rack.
Switching Racks
Section titled “Switching Racks”Change the default rack:
# Switch to stagingrack-gateway switch staging
# Verifyrack-gateway rack# Current rack: staging# Gateway URL: https://gateway-staging.example.com# Status: Logged in as developer@company.com# Token expires: 2026-12-01T10:00:00ZPer-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. Deploy approval commands also
take a comma-separated list of racks, or all.
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": "Fz2kQ...", "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": "pR7wD...", "email": "developer@company.com", "expires_at": "2024-02-15T10:30:00Z", "session_id": 2048, "channel": "cli" } }}Removing a Rack
Section titled “Removing a Rack”logout ends your session on that rack’s gateway, then removes the rack, with its URL and session token, from your
config:
rack-gateway logout -r stagingIf the gateway is gone for good, rack-gateway logout -r staging --local removes the rack without contacting 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 an API token instead of a login. CI has no config file, so give it the gateway URL too:
# In your CI environmentexport RACK_GATEWAY_API_TOKEN="rgw_..."export RACK_GATEWAY_URL="https://gateway-prod.example.com"
rack-gateway deploy --app myapp --waitPrecedence Order
Section titled “Precedence Order”When determining which rack to use:
--rackflag (highest priority)RACK_GATEWAY_RACKenvironment variableRACK_GATEWAY_URL(an unnamed rack, used withRACK_GATEWAY_API_TOKEN)currentin config file (default)
Troubleshooting
Section titled “Troubleshooting”“Rack not found”
Section titled ““Rack not found””Error: rack production not found. Use 'rack-gateway racks' to list available racksThe 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. Sign in to the affected rack again (its URL is kept):
rack-gateway login productionDifferent 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 rack shows who you’re logged in as on the current rack; rack-gateway rack -r staging shows your
login on staging.
Next Steps
Section titled “Next Steps”- Commands - Full command reference
- MFA Verification - Step-up authentication