wheels env switch
Switch to a different environment in your Wheels application.
Synopsis
Description
The wheels env switch
command changes the active environment for your Wheels application. It updates configuration files, environment variables, and optionally restarts services to apply the new environment settings.
Arguments
name
Target environment name
Required
Options
--check
Validate before switching
true
--restart
Restart application after switch
false
--backup
Backup current environment
false
--force
Force switch even with issues
false
--quiet
Suppress output
false
--help
Show help information
Examples
Switch to staging
Switch with application restart
Force switch without validation
Switch with backup
Quiet switch for scripts
What It Does
Validates Target Environment:
Checks if environment exists
Verifies configuration
Tests database connection
Updates Configuration:
Sets WHEELS_ENV variable
Updates .wheels-env file
Modifies environment.cfm if needed
Applies Changes:
Clears caches
Reloads configuration
Restarts services (if requested)
Verifies Switch:
Confirms environment active
Checks application health
Reports status
Output Example
Environment File Updates
.wheels-env
Before:
After:
Environment Variables
Updates system environment:
Validation Process
Before switching, validates:
Configuration:
File exists
Syntax valid
Required settings present
Database:
Connection works
Tables accessible
Migrations current
Dependencies:
Required services available
File permissions correct
Resources accessible
Switch Strategies
Safe Switch (Default)
Full validation
Graceful transition
Rollback on error
Fast Switch
Skip validation
Immediate switch
Use with caution
Zero-Downtime Switch
Prepare new environment
Switch load balancer
No service interruption
Backup and Restore
Create Backup
Restore from Backup
Manual Restore
Service Management
With Restart
Restarts:
Application server
Cache services
Background workers
Service-Specific
Pre/Post Hooks
Configure in .wheels-cli.json
:
Environment-Specific Actions
Development → Production
Production → Development
Integration
CI/CD Pipeline
Deployment Scripts
Rollback
If switch fails or causes issues:
Troubleshooting
Switch Failed
Check validation errors
Verify target environment exists
Use
--force
if necessary
Application Not Responding
Check service status
Review error logs
Manually restart services
Database Connection Issues
Verify credentials
Check network access
Test connection manually
Best Practices
Always Validate: Don't skip checks in production
Use Backups: Enable backup for critical switches
Test First: Switch in staging before production
Monitor After: Check application health post-switch
Document Changes: Log environment switches
Security Considerations
Production switches require confirmation
Sensitive configs protected
Audit trail maintained
Access controls enforced
Notes
Some changes require application restart
Database connections may need reset
Cached data cleared on switch
Background jobs may need restart
See Also
Last updated
Was this helpful?