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:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
reason | string | No | ”manual” | Reason for maintenance (logged for audit) |
timeoutMs | number | No | 300000 | Maximum wait time for markets to resolve (milliseconds) |
| Field | Type | Description |
|---|---|---|
success | boolean | Always true on successful activation |
message | string | Human-readable status message |
safeToDeploy | boolean | true if safe to deploy, false if waiting for markets |
currentPhase | string | Current duel phase: IDLE, COUNTDOWN, FIGHTING, ANNOUNCEMENT |
marketStatus | string | Market status: resolved, active, locked |
pendingMarkets | number | Number of unresolved markets |
enteredAt | number | Unix timestamp (milliseconds) when maintenance mode entered |
ADMIN_CODE:
Check Maintenance Status
Returns current maintenance mode state and safe-to-deploy status. Endpoint:GET /admin/maintenance/status
Headers:
| Field | Type | Description |
|---|---|---|
active | boolean | true if maintenance mode active, false otherwise |
enteredAt | number | null | Unix timestamp when entered (null if not active) |
reason | string | null | Reason for maintenance (null if not active) |
safeToDeploy | boolean | true if safe to deploy (always true if not active) |
currentPhase | string | Current duel phase |
marketStatus | string | Market status |
pendingMarkets | number | Number of unresolved markets |
elapsedMs | number | null | Time elapsed since entering (null if not active) |
ADMIN_CODE:
Exit Maintenance Mode
Resumes normal operations (duel cycles and betting markets). Endpoint:POST /admin/maintenance/exit
Headers:
| Field | Type | Description |
|---|---|---|
success | boolean | Always true on successful deactivation |
message | string | Human-readable status message |
duration | number | Total time spent in maintenance mode (milliseconds) |
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