Skip to main content

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.
Headers:
Request Body:
Parameters:
  • reason (string) - Reason for maintenance (logged for audit)
  • timeoutMs (number) - Maximum wait time in milliseconds (default: 300000 = 5 minutes)
Response:
Response Fields:
  • success (boolean) - Whether maintenance mode was entered successfully
  • status.active (boolean) - Whether maintenance mode is currently active
  • status.safeToDeploy (boolean) - Whether it’s safe to deploy now
  • status.currentPhase (string) - Current duel phase (IDLE, FIGHTING, etc.)
  • status.marketStatus (string) - Market status (resolved, betting, etc.)
  • status.pendingMarkets (number) - Number of unresolved markets
  • status.enteredAt (string) - ISO timestamp when maintenance mode was entered
  • status.reason (string) - Reason for maintenance

Exit Maintenance Mode

Resumes normal operations (duel cycles, betting markets).
Headers:
Request Body:
Response:

Check Status

Get current maintenance mode status without changing it.
Headers:
Response:

Safe to Deploy Conditions

The API reports safeToDeploy: true when:
  1. Maintenance mode is active (entered via API)
  2. Not in active duel phase (not FIGHTING, COUNTDOWN, or ANNOUNCEMENT)
  3. No pending betting markets (all markets resolved or none exist)
Unsafe Conditions:
  • 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
Timeout Behavior:
  • 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:
Action: Wait and retry status check. Maintenance mode remains active.

Invalid Admin Code

HTTP Status: 401 Unauthorized

Server Not Ready

If server is still starting after deployment:
HTTP Status: 503 Service Unavailable Action: Wait for health check to pass, then retry.

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:
Manually resolve if needed:

Health Check Failing

If server doesn’t become healthy after deployment:

Security

Admin Code Protection

The maintenance mode API requires ADMIN_CODE header:
Never commit ADMIN_CODE to git. Store in GitHub Secrets or environment variables.

Rate Limiting

Maintenance mode endpoints are rate-limited:

Vast.ai Deployment

Complete Vast.ai deployment guide

Configuration

Environment variables and settings

Deployment Guide

General deployment documentation

Troubleshooting

Common issues and solutions