Maintenance Mode API Reference
This document provides complete API reference for the maintenance mode endpoints introduced in February 2026.Overview
The maintenance mode API provides graceful deployment coordination for the streaming duel system. It prevents data loss and market inconsistency by pausing new duel cycles and waiting for active markets to resolve before allowing deployments. Base URL:https://your-server.com (e.g., https://hyperscape.gg)
Authentication: All endpoints require ADMIN_CODE header:
Endpoints
Enter Maintenance Mode
Pauses new duel cycles and waits for active markets to resolve. Endpoint:POST /admin/maintenance/enter
Headers:
Response (200 OK):
Error Responses:
401 Unauthorized - Missing or invalid
ADMIN_CODE:
Check Maintenance Status
Returns current maintenance mode state and safe-to-deploy status. Endpoint:GET /admin/maintenance/status
Headers:
Response (Not Active):
ADMIN_CODE:
Exit Maintenance Mode
Resumes normal operations (duel cycles and betting markets). Endpoint:POST /admin/maintenance/exit
Headers:
Error Responses:
401 Unauthorized - Missing or invalid
ADMIN_CODE:
Workflow Examples
Manual Deployment
Automated CI/CD
Emergency Rollback
State Machine
Maintenance Mode States
Duel Phase States
Market States
Integration Examples
Node.js
Python
Best Practices
Timeout Configuration
Recommended Timeouts:- Development: 60000ms (1 minute) - faster iteration
- Staging: 180000ms (3 minutes) - balance speed and safety
- Production: 300000ms (5 minutes) - maximum safety
- Duel duration: ~60-120 seconds
- Market resolution: ~10-30 seconds
- Network latency: ~1-5 seconds
- Buffer: 2x expected duration
Error Handling
Always exit maintenance mode - even on deployment failure:Monitoring
Log all maintenance mode events:- Entry timestamp and reason
- Safe state achieved timestamp
- Exit timestamp and duration
- Any timeouts or errors
- Maintenance mode timeout (markets didn’t resolve)
- Failed to exit maintenance mode
- Maintenance mode active > 10 minutes
Health Endpoint Integration
The/health endpoint includes maintenance mode status:
- Load balancer health checks
- Monitoring dashboards
- Automated alerts
Implementation Details
Source Code:packages/server/src/startup/maintenance-mode.ts
Dependencies:
- DuelScheduler system (pauses cycles)
- Betting market system (locks markets)
- Streaming state (monitors phases)
Related Documentation
- Deployment Guide: docs/deployment-best-practices.md
- Streaming Guide: docs/streaming-configuration.md
- Railway Setup: docs/railway-dev-prod.md
- Environment Variables: packages/server/.env.example
Changelog
- February 26, 2026 (Commit
30b52bd): Initial implementation- Added
/admin/maintenance/enterendpoint - Added
/admin/maintenance/statusendpoint - Added
/admin/maintenance/exitendpoint - Integrated with CI/CD workflow
- Added helper scripts
- Added
Support
For issues or questions:- GitHub Issues: https://github.com/HyperscapeAI/hyperscape/issues
- Documentation: https://github.com/HyperscapeAI/hyperscape/tree/main/docs
- Discord: Join our community