Documentation
¶
Overview ¶
Command leaderboardd is experimental: its command-line interface may change in a minor release; see https://nsgo.games/docs/stability/.
Command leaderboardd runs the self-hosted leaderboard service as a standalone HTTP server, persisting scores in Postgres, SQLite or a directory of JSON Lines files.
leaderboardd init -config leaderboards.yaml leaderboardd genkey -key server.pem leaderboardd serve -config leaderboards.yaml -keyset keys.yaml -data scores -addr :8082 LEADERBOARD_POSTGRES_DSN=postgres://... leaderboardd serve -config leaderboards.yaml -keyset keys.yaml -addr :8082
init writes a configuration with one all-time high-score board to edit. genkey writes a new game server signing key for score proofs and prints the serverKeys entry to add to the configuration; the game server reads the key with authtoken.ParsePrivateKey and signs with selfhost.NewProofSigner. serve runs the service until SIGINT or SIGTERM, verifying player tokens with the account service's key set file (accountsd genkey writes it). It accepts only tokens for the configuration's audience ("leaderboard" by default), which devices get from the account service's refresh, and refuses to start when that audience is the key set's, which names the game's servers. With metrics set in the configuration, serve also answers GET /healthz, GET /readyz (200 while the database answers a ping, or while the -data directory is there, else 503) and GET /metrics (Prometheus text: requests by route and status with latency, entries per board, and dropped audit records when admin is set) on that address, a listener of its own.
When the configuration has an admin: block, serve also runs the admin listener it describes (package admin) on its own address, accepting operator sessions and the account service's "admin" bearer tokens, with the leaderboard's operator routes (selfhost.Service.AdminRoutes: list boards and entries, delete or hide an account's entries, reset a board); without the block no admin route exists.