Skip to main content

Overview

Hyperscape includes a comprehensive admin dashboard for server management, monitoring, and zero-downtime deployments. The dashboard provides:
  • Live Controls - HLS stream preview, maintenance mode toggle, server restart
  • Live Logs - 1000-entry ring buffer with auto-refresh
  • Maintenance Mode - Graceful server pause/resume for deployments
  • User Management - View all users, characters, and sessions
  • Activity Log - Server-side event history with filtering
Admin Live Controls and Maintenance Mode added in PR #1015 (March 12, 2026).

Accessing the Dashboard

Setup

  1. Set admin code in packages/server/.env:
  2. Navigate to admin panel:
  3. Enter admin code when prompted
The ADMIN_CODE is required in production for security. Without it, admin endpoints are inaccessible.

Live Controls Tab

The Live Controls tab provides real-time server management with HLS stream preview, maintenance mode controls, and live log streaming.

Features

HLS Stream Preview

Embedded video player showing live HLS stream from /live/stream.m3u8

Maintenance Mode Toggle

Pause/resume game with safe-to-deploy status

Server Restart

Restart server process (requires PM2)

Live Logs

1000-entry ring buffer with auto-refresh every 3s

Stream Preview

The dashboard includes an embedded HLS video player:
Features:
  • Auto-play with muted audio
  • Low-latency mode for minimal delay
  • Fallback to native HLS on Safari

Game State Controls

Status Display:
  • Maintenance mode active/inactive
  • Safe to deploy (yes/no)
  • Current phase (IDLE, FIGHTING, COUNTDOWN, etc.)
  • Viewer count
Control Actions:
  • Pause Game - Enters maintenance mode, waits for safe state
  • Resume Game - Exits maintenance mode, resumes duel cycles
  • Restart Process - Sends SIGTERM to server (requires PM2)

Live Logs

Features:
  • 1000 most recent log entries
  • Auto-refresh every 3 seconds
  • Color-coded by log level (DEBUG, INFO, WARN, ERROR)
  • Auto-scroll to bottom
  • Manual refresh button
Log Entry Format:

Maintenance Mode

Maintenance mode enables zero-downtime deployments by gracefully pausing the game.

How It Works

When maintenance mode is entered:
  1. Pause new duel cycles - Current cycle completes, no new cycles start
  2. Lock betting markets - No new bets accepted
  3. Wait for resolution - Current market resolves
  4. Report safe state - API returns safeToDeploy: true

API Endpoints

All endpoints require x-admin-code header.

Enter Maintenance Mode

Exit Maintenance Mode

Check Status

Safe to Deploy Conditions

The system reports safeToDeploy: true when:
  • ✅ Maintenance mode is active
  • ✅ Not in active duel phase (FIGHTING, COUNTDOWN, ANNOUNCEMENT)
  • ✅ No pending betting markets (or all markets resolved)

Helper Scripts

CI/CD Integration

The Vast.ai deployment workflow automatically uses maintenance mode:

Maintenance Banner

The client automatically displays a maintenance banner when the server enters maintenance mode.

Features

  • Polls /health endpoint every 5 seconds
  • Displays red warning banner when maintenanceMode: true
  • Visible across all screens (game, admin, leaderboard, streaming)
  • Auto-dismisses when maintenance mode exits

Implementation


Logger Ring Buffer

The server maintains a 1000-entry ring buffer of recent log entries for live streaming to the admin dashboard.

Configuration

API Endpoint

Log Levels

Usage


Server Restart

The admin dashboard can restart the server process via the /admin/restart endpoint.

API Endpoint

Behavior

  1. Validates admin code
  2. Waits 2 seconds (allows response to be sent)
  3. Calls process.exit(0)
  4. PM2 automatically restarts the server
This endpoint requires a process manager (PM2) to automatically restart the server. Without PM2, the server will exit and not restart.

PM2 Configuration


User Management Tab

View and manage all users, characters, and sessions.

Features

  • User List - All registered users with Privy IDs
  • Character List - All characters with levels and stats
  • Session List - Active player sessions
  • Search & Filter - Find specific users or characters

Activity Log Tab

Server-side event history with filtering and search.

Features

  • Event Types - Combat, inventory, trading, banking, etc.
  • Time Range - Filter by date/time range
  • Player Filter - Show events for specific player
  • Export - Download activity log as CSV

Security

Admin Code

The ADMIN_CODE environment variable protects all admin endpoints:
Best Practices:
  • Use a strong, random admin code (32+ characters)
  • Never commit admin code to git
  • Rotate admin code periodically
  • Use different codes for dev/staging/production

Rate Limiting

Admin endpoints are not rate-limited to allow rapid operations during incidents.
Protect your admin code carefully. Anyone with the code can restart the server, enter maintenance mode, and view all logs.

Troubleshooting

Logs Not Appearing

Symptom: Live logs tab shows “No logs available…” Causes:
  1. Admin code incorrect
  2. Ring buffer empty (server just started)
  3. Auto-refresh disabled
Solutions:
  • Verify admin code in server .env
  • Wait for server to generate logs
  • Enable auto-refresh toggle

Maintenance Mode Not Working

Symptom: Game doesn’t pause when entering maintenance mode Causes:
  1. Admin code incorrect
  2. Streaming duel scheduler not running
  3. Environment variable not set
Solutions:
  • Check /admin/maintenance/status endpoint
  • Verify STREAMING_DUEL_ENABLED=true
  • Check PM2 logs: bunx pm2 logs hyperscape-duel

Server Restart Fails

Symptom: Server doesn’t restart after clicking restart button Causes:
  1. PM2 not running
  2. PM2 autorestart disabled
  3. Server crashed during restart
Solutions:
  • Check PM2 status: bunx pm2 status
  • Verify autorestart: true in ecosystem.config.cjs
  • Check PM2 logs for crash details

Deployment

Production deployment with maintenance mode integration

Configuration

Environment variables and server configuration

Monitoring

Health checks and alerting

Troubleshooting

Common issues and solutions