What is Maintenance Mode?
When maintenance mode is active:- ✅ Your server keeps running
- ⛔ All requests receive a 503 Service Unavailable response
- 🎨 Users see a custom HTML page or JSON message
- 🔑 You can create a secret bypass for your team
- ↪️ You can redirect users to an external status page
Basic Commands
Activate Maintenance Mode
Deactivate Maintenance Mode
Command Options
Thedown command supports several options:
—message
Customize the maintenance message shown to users.—retry
Set theRetry-After header value in seconds.
—secret
Create a bypass token for your team to access the application.-
Regular user access:
-
Team access with secret:
-
Subsequent requests:
—render
Specify a custom HTML template to display.—norender
Force JSON responses even for browser requests (useful for pure APIs).—redirect
Redirect all requests to a specific URL.HTML Templates
Template Structure
Creating Custom Templates
- Create the directory structure:
- Create your template file:
templates/render/down/myfolder/default.html
- Use your template:
Available Template Variables
{{MESSAGE}}- Your custom message (from —message flag){{RETRY}}- Retry time in seconds (from —retry flag){{TIMESTAMP}}- Maintenance activation timestamp (ISO 8601 format)
Real-World Examples
Example 1: Scheduled Maintenance
Example 2: Emergency Shutdown
Example 3: Database Migration
Example 4: External Status Page
Example 5: API-Only Maintenance
Option Conflicts
❌ Cannot Combine
Some options cannot be used together: —render and —norender:✅ Valid Combinations
Maintenance File
Maintenance state is stored in:File Structure
Check Maintenance Status
Check if file exists:Troubleshooting
Application Still Responding Normally
Problem: Server continues to process requests after runningdown command.
Solution: Restart the server to load the maintenance file:
Template Not Found
Problem:Secret Not Working
Problem: Secret bypass URL not working. Solutions:- Clear browser cookies
- Test in incognito/private mode
- Verify secret in maintenance.json:
Cannot Remove Maintenance File
Problem:Best Practices
1. Store Secrets Securely
Don’t hardcode secrets in scripts:2. Use Descriptive Templates
Create specific templates for different maintenance types:3. Set Appropriate Retry Times
- Quick fixes: 30-60 seconds
- Updates: 5-10 minutes (300-600 seconds)
- Major migrations: 15-30 minutes (900-1800 seconds)
4. Automate with Scripts
Create deployment scripts:deploy.sh
5. Notify Users in Advance
Before enabling maintenance:- Send email notifications
- Post on status page
- Update social media
- Set up monitoring alerts
Comparison with Laravel
| Laravel | Rust Ironclad | Description |
|---|---|---|
php artisan down | cargo run --bin ironclad -- down | Enable maintenance |
php artisan up | cargo run --bin ironclad -- up | Disable maintenance |
--secret="token" | --secret "token" | Bypass access |
--render="view" | --render "template" | Custom view |
--redirect="/url" | --redirect "/url" | Redirect |
--retry=600 | --retry 600 | Retry time |
Related Documentation
Database Command
Check database before maintenance
Storage Commands
Manage storage during maintenance
CLI Overview
View all CLI commands
Middleware
How maintenance middleware works