Tooling

Monitoring

Watch a running game server in the terminal with mavonengine dashboard, or in the browser with the http-monitoring plugin.

The game server measures itself: CPU, bandwidth, tick time against the tick budget, world, physics and memory stats, its job queue, connected players, recent log output and the HTTP requests it received.

Terminal dashboard

# Local server on the default HTTP port (8050)
npx @mavonengine/cli dashboard

# Remote server with a metrics token
MAVONENGINE_METRICS_TOKEN=secret npx @mavonengine/cli dashboard --host game.example.com --port 8050

# No server needed: simulated data
npx @mavonengine/cli dashboard --sim

mavonengine dev and mavonengine create show the same dashboard.

OptionDefault
--host <host>localhostServer host
--port <port>8050Server HTTP port
--url <url>Full metrics URL, overrides --host and --port
--token <token>$MAVONENGINE_METRICS_TOKEN, then $MAVONENGINE_ADMIN_TOKENMetrics token, or the server's admin token
--interval <ms>1000Poll interval
--theme <name>darkdark, dracula, nord, tokyoNight, gruvbox, matrix, monochrome, highContrast, light
--transparentLet a transparent terminal background show through
--simSimulated data instead of a server

Keys: q quits, r refreshes, o opens the game in the browser, 1–7 switch between the Overview, Players, Logs, HTTP, Network, Routes and Plugins tabs, and 8 to the Database tab when the server has a database plugin. The mouse wheel scrolls the lists.

Queue

The Overview tab graphs the server's job queue next to CPU, network and tick: jobs queued, processed and failed over time, with how many are queued and running now and how many were processed, retried and failed in the graph's window. Its title says whether the queue is in memory or the database, and not worked here for a server that only dispatches. A server older than the queue shows the Overview without it.

Players

Each connected player with its position and connection. When the server has an auth plugin, an Account column shows who each player is, with guests marked, and the player details show the account. The state sync table of the Network tab gets the same column.

HTTP

Every request the game server received: the client files, your onHttp routes, geckos.io signaling and WebSocket upgrades. Query strings are left out since they can hold tokens. The game traffic itself is WebRTC and shows on the Players and Network tabs.

Network

The game socket while developing. Only a server that is not running in production records packets, see network debugging.

  • State sync: each player with the entities in its last state update, its last acknowledged input and the size and tick of that update (red when it fell behind the others), plus the number of synced entities no player is in range of.
  • By message: the traffic of the last 5 seconds by message name and direction: packets per second, average size and bytes per second.
  • Packets: every packet and network event, newest first, with its client, size, tick and input sequence id. p shows the pings, e only the events (connect, disconnect, dropped, sync_enter, sync_leave). Click a packet, or move with the arrow keys (or j / k), to see its payload as it went over the wire; esc closes it. The server drops the payloads of old packets, so only recent ones can be opened.

Routes

Every HTTP endpoint the server has: the engine's own, the ones your server registered in onHttp and those of plugins, each with its method, path, whether it only exists in development, where it comes from, who may call it and what it does. The list is read from the running server, so a new route shows up without being declared anywhere. See Describing routes.

Plugins

The plugins in the project's mavonengine.json with their version, whether they are enabled, where they run and how many endpoints and prefabs they have. Pick one with ↑ / ↓ to see its description, supported engine versions, license, prefabs and the HTTP endpoints it registered. A server plugin that is enabled but not running in this server shows as not loaded.

Below it, Available to install lists the official plugins the project doesn't have yet. Under mavonengine dev, select one and press i: the dashboard asks whether you checked its source, then installs it, adds it to mavonengine.json and restarts the dev servers. A dashboard started on its own with mavonengine dashboard only shows the command.

Database

Looks into the server's database. The tab only shows up when the server runs a database plugin such as @mavonengine/sqlite.

  • It lists the tables with the plugin each belongs to (by its table prefix, game for the rest) and their number of rows, shows the rows of the selected table and, below, the migrations each plugin ran.
  • ↑ / ↓ (or j / k, or a click) pick a table, ← / → (or page up / page down) page through its rows.
  • It only reads, and only while the tab shows, every 5 seconds.
  • The database holds what players did, so the server only shows it with its admin token: start the dashboard with --token <admin token> for a server that has one. Without one it only answers on the server's own machine.

Server access

The dashboard reads GET /api/game/metrics, /api/game/logs, /api/game/requests, /api/game/routes and /api/game/plugins. Configure them on the server:

const server = new MyServer(logger, physicsWorld, {
  httpPort: 8050,
  metrics: {
    token: process.env.METRICS_TOKEN,
    // Recent log entries kept, 0 turns the logs endpoint off
    logBufferSize: 500,
    // Recent HTTP requests kept, 0 turns the requests endpoint off
    requestLogSize: 500,
  },
})
  • With no token, the endpoints only answer requests from localhost.
  • With NODE_ENV=production and no token, they are turned off.
  • metrics.enabled: false turns them off everywhere.
  • The token is sent as Authorization: Bearer <token> or ?token=<token>.
  • The server's admin token is taken as well, and turns the endpoints on in production by itself. The metrics token stays read-only: it administers nothing.
  • The Database tab reads GET /api/game/database, which takes the admin token only, not the metrics token.

Browser dashboard

The @mavonengine/http-monitoring plugin serves the same dashboard from the game server, behind HTTP Basic auth.

npx @mavonengine/cli install @mavonengine/http-monitoring

Then open http://<your server>:8050/monitoring/.

Logging in

The dashboard logs in with the game server's admin token, so it needs no secret of its own:

MAVONENGINE_ADMIN_TOKEN=… npm start

In the browser's login prompt, enter the token as the password; the user name can be anything. Tools can send it as Authorization: Bearer <token> instead.

An htpasswd file adds a login per person next to that:

htpasswd -cB .htpasswd alice
{
  "plugins": {
    "@mavonengine/http-monitoring": { "enabled": true, "options": { "htpasswd": ".htpasswd" } }
  }
}

The path is relative to the project root; MAVONENGINE_MONITORING_HTPASSWD works too. Keep the file out of git. Changes are picked up while the server runs. Supported hashes: bcrypt, Apache MD5 ($apr1$) and SHA-1 ({SHA}).

MAVONENGINE_MONITORING_USER and MAVONENGINE_MONITORING_PASSWORD, the plugin's own single login, still work but are deprecated: use the admin token instead.

No admin token and no htpasswd file: in development the dashboard only answers the server's own machine; in production it stays off.

Basic auth sends the password with every request, so put HTTPS in front of a public server. After 10 failed logins an address is locked out for 5 minutes.

Options

OptionDefault
path/monitoringWhere the dashboard is served. Can't be /
htpasswd$MAVONENGINE_MONITORING_HTPASSWDhtpasswd file, relative to the project root
realmMavonEngine monitoringShown in the browser's login prompt
pollIntervalMs1000How often the page fetches new data, at least 250

Without mavonengine.json, pass it to the server directly:

import { createHttpMonitoring } from '@mavonengine/http-monitoring'

const server = new MyServer(logger, physicsWorld, {
  plugins: [createHttpMonitoring({ htpasswd: '/etc/mygame/monitoring.htpasswd' })],
})