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
-
Set admin code in
packages/server/.env: -
Navigate to admin panel:
- Enter admin code when prompted
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.m3u8Maintenance 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:- 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
- 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
Maintenance Mode
Maintenance mode enables zero-downtime deployments by gracefully pausing the game.How It Works
When maintenance mode is entered:- Pause new duel cycles - Current cycle completes, no new cycles start
- Lock betting markets - No new bets accepted
- Wait for resolution - Current market resolves
- Report safe state - API returns
safeToDeploy: true
API Endpoints
All endpoints requirex-admin-code header.
Enter Maintenance Mode
Exit Maintenance Mode
Check Status
Safe to Deploy Conditions
The system reportssafeToDeploy: 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
/healthendpoint 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
- Validates admin code
- Waits 2 seconds (allows response to be sent)
- Calls
process.exit(0) - PM2 automatically restarts the server
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
TheADMIN_CODE environment variable protects all admin endpoints:
- 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.Troubleshooting
Logs Not Appearing
Symptom: Live logs tab shows “No logs available…” Causes:- Admin code incorrect
- Ring buffer empty (server just started)
- Auto-refresh disabled
- 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:- Admin code incorrect
- Streaming duel scheduler not running
- Environment variable not set
- Check
/admin/maintenance/statusendpoint - 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:- PM2 not running
- PM2 autorestart disabled
- Server crashed during restart
- Check PM2 status:
bunx pm2 status - Verify
autorestart: trueinecosystem.config.cjs - Check PM2 logs for crash details
Related Documentation
Deployment
Production deployment with maintenance mode integration
Configuration
Environment variables and server configuration
Monitoring
Health checks and alerting
Troubleshooting
Common issues and solutions