Skip to main content

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:
Request Body:
Parameters: Response (200 OK):
Response Fields: Error Responses: 401 Unauthorized - Missing or invalid ADMIN_CODE:
409 Conflict - Already in maintenance mode:
504 Gateway Timeout - Markets didn’t resolve within timeout:
Example (cURL):
Example (JavaScript):

Check Maintenance Status

Returns current maintenance mode state and safe-to-deploy status. Endpoint: GET /admin/maintenance/status Headers:
Response (200 OK):
Response Fields: Response (Not Active):
Error Responses: 401 Unauthorized - Missing or invalid ADMIN_CODE:
Example (cURL):
Example (JavaScript):

Exit Maintenance Mode

Resumes normal operations (duel cycles and betting markets). Endpoint: POST /admin/maintenance/exit Headers:
Response (200 OK):
Response Fields: Error Responses: 401 Unauthorized - Missing or invalid ADMIN_CODE:
409 Conflict - Not in maintenance mode:
Example (cURL):
Example (JavaScript):

Workflow Examples

Manual Deployment

Automated CI/CD

Emergency Rollback

State Machine

Maintenance Mode States

NOT_ACTIVE: Normal operations, duel cycles running ENTERING: Pausing new cycles, locking markets WAITING: Waiting for active markets to resolve SAFE: Safe to deploy (no active duels or markets) TIMEOUT: Timeout reached, deployment can proceed (with caution) EXITING: Resuming operations

Duel Phase States

IDLE: No active duel, safe to deploy COUNTDOWN: Duel starting soon, wait for completion FIGHTING: Duel in progress, wait for completion ANNOUNCEMENT: Winner announced, wait for market resolution

Market States

OPEN: Accepting bets, not safe to deploy LOCKED: No new bets, waiting for resolution RESOLVED: Payouts complete, safe to deploy

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
Considerations:
  • 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
Alert on:
  • 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:
Response:
Use for:
  • 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)
State Storage: In-memory (resets on server restart) Thread Safety: Single-threaded Node.js (no race conditions)

Changelog

  • February 26, 2026 (Commit 30b52bd): Initial implementation
    • Added /admin/maintenance/enter endpoint
    • Added /admin/maintenance/status endpoint
    • Added /admin/maintenance/exit endpoint
    • Integrated with CI/CD workflow
    • Added helper scripts

Support

For issues or questions: