Overview
The Maintenance Mode API enables graceful deployments without data loss or market inconsistency. It pauses new duel cycles, waits for active markets to resolve, and reports when it’s safe to deploy.API Endpoints
Enter Maintenance Mode
Pauses new duel cycles and waits for active markets to resolve.reason(string) - Reason for maintenance (logged for audit)timeoutMs(number) - Maximum wait time in milliseconds (default: 300000 = 5 minutes)
success(boolean) - Whether maintenance mode was entered successfullystatus.active(boolean) - Whether maintenance mode is currently activestatus.safeToDeploy(boolean) - Whether it’s safe to deploy nowstatus.currentPhase(string) - Current duel phase (IDLE, FIGHTING, etc.)status.marketStatus(string) - Market status (resolved, betting, etc.)status.pendingMarkets(number) - Number of unresolved marketsstatus.enteredAt(string) - ISO timestamp when maintenance mode was enteredstatus.reason(string) - Reason for maintenance
Exit Maintenance Mode
Resumes normal operations (duel cycles, betting markets).Check Status
Get current maintenance mode status without changing it.Safe to Deploy Conditions
The API reportssafeToDeploy: true when:
- Maintenance mode is active (entered via API)
- Not in active duel phase (not FIGHTING, COUNTDOWN, or ANNOUNCEMENT)
- No pending betting markets (all markets resolved or none exist)
- Active duel in progress (FIGHTING phase)
- Countdown in progress (COUNTDOWN phase)
- Announcement in progress (ANNOUNCEMENT phase)
- Unresolved betting markets exist
What Maintenance Mode Does
Pauses New Duel Cycles
Locks Betting Markets
Waits for Resolution
The API waits for:- Current duel to complete
- Betting markets to resolve
- Payouts to be distributed
- If timeout is reached before resolution, returns
safeToDeploy: false - Caller should wait and retry status check
- Maintenance mode remains active until explicitly exited
Helper Scripts
Pre-Deploy Maintenance
Post-Deploy Resume
CI/CD Integration
GitHub Actions Workflow
The Vast.ai deployment workflow automatically uses maintenance mode:Required GitHub Secrets
Manual Usage
Enter Maintenance Mode
Wait for Safe Deploy
Deploy
Exit Maintenance Mode
Error Handling
Timeout Exceeded
If timeout is reached before markets resolve:Invalid Admin Code
Server Not Ready
If server is still starting after deployment:Benefits
Prevents Data Loss
- No interrupted duel cycles
- No orphaned betting markets
- No inconsistent game state
Ensures Market Integrity
- All markets resolve before deployment
- Payouts distributed correctly
- No stuck funds
Clean Duel Cycle Boundaries
- Current cycle completes naturally
- New cycle starts after deployment
- No mid-duel interruptions
Zero-Downtime Deployments
- Server continues running during deployment
- Active duels complete normally
- New duels pause until deployment finishes
Monitoring
Check Maintenance Status
Monitor Pending Markets
Monitor Current Phase
Troubleshooting
Maintenance Mode Stuck
If maintenance mode doesn’t exit:Markets Not Resolving
Check market status:Health Check Failing
If server doesn’t become healthy after deployment:Security
Admin Code Protection
The maintenance mode API requiresADMIN_CODE header:
Rate Limiting
Maintenance mode endpoints are rate-limited:Related Documentation
Vast.ai Deployment
Complete Vast.ai deployment guide
Configuration
Environment variables and settings
Deployment Guide
General deployment documentation
Troubleshooting
Common issues and solutions