Skip to Content
MineDuels

Restarts and the game server gate

Drain a server or proxy before a restart, and keep players who are not in a match out of the game servers.

Two features keep restarts and game servers tidy:

  • Drain stops new players and matches from going to a server or proxy, so it can be restarted when it is empty.
  • The gate lets only players of a match onto a game server.

Both need the Velocity plugin from the same version as the backends. Drain also works on a single server without cross-server.

Drain a backend

Run on the server you want to restart:

/md drain start
/md drain start Updating to 0.10.1
/md drain status
/md drain stop

/md drain needs mineduels.admin. The reason is optional and only shown in status and the webhook.

To drain from a script, or to drain another server of the network from one place, use the web API.

Example status output while two matches are still running:

[MineDuels] Draining for 3 min (Updating to 0.10.1): 4 players, 2 running matches, 0 pending assignments.

When nothing is left it adds Empty.

What a draining server refuses

ActionResult
/queue, queue menu, queue signsThe player is told the server is about to restart (queue.draining in messages.yml).
/duel and accepting a duelSame message.
Starting a party game, party duel or Red RoverSame message.
Hosting a tournamentSame message.
A match assigned by the matchmakerThe server cancels it and the players queue again with their waiting time kept.
/spectate from another serverThe server answers that the player is not in a match.
/serversThe entry shows Restarting and cannot be chosen (cross-server.server-draining).

The other servers see the flag in the heartbeat within 2 seconds. They stop choosing the server:

Server roleEffect
LobbyNot chosen as the least full lobby, not chosen as a return lobby, not shown as joinable. The proxy sends new players to another lobby.
GameReports no free arenas, so the matchmaker never picks it.

What a draining server still allows

ActionWhy
Running matches finishNobody loses a match.
A player who disconnected from a running match can rejoin itThe match is still running, so the rejoin ticket still works.
Staff with mineduels.proxy.bypassThe proxy lets them connect to a draining lobby.

Drain is not saved. A restart clears it, which is the point.

Examples

Restart a game server without cutting matches:

/md drain start restart for update

Wait for the drain-empty message in your webhook, then restart the server from the panel.

Cancel a drain you started by mistake:

/md drain stop

Drain every lobby at once before a network update: run /md drain start on each lobby. Players are then sent to the lobbies that are still up. When no lobby is up, players who join are sent to the least full lobby the proxy can find, or refused (see drain.no-alternative below).

Drain a proxy

Run in the proxy console or in game with mineduels.proxy.admin:

/mdproxy drain start
/mdproxy drain start moving the proxy to a new host
/mdproxy drain status
/mdproxy drain stop

While a proxy drains:

ThingBehaviour
New loginsRefused with "This proxy is restarting. Try again in a few minutes." Players with the bypass permission can still join.
Players on the proxyThey stay. Nobody is kicked.
Players from another proxyThe other proxies do not send players here.
/mdproxyThe proxy and any draining backend are marked [draining].

With several proxies in different regions, new players join through the proxies that are not draining.

Example for a two proxy network:

# on proxy eu
/mdproxy drain start eu proxy update
# players join through proxy sg while eu empties
# restart eu when the webhook says proxy-empty

The game server gate

A game server is for matches. The proxy lets a player connect to one only when:

  1. The player is in a match that was just assigned to that server (queue match, duel, party game or tournament), or
  2. The player was asked to go there to spectate, or
  3. The player holds a rejoin ticket after a disconnect during a match, or
  4. The player has the bypass permission.

Everyone else is told "Game servers are only for players in a match." A player who just joined the network is sent to a lobby instead of being disconnected.

Examples of what the gate does

SituationResult
A player types /server game-1Refused.
A player connects with a forced host that points to game-1Sent to a lobby.
A player is paired in the queueAllowed for gate.admit-seconds (default 90), until they connect.
A player loses connection in round 2 and logs in again within disconnect-grace-secondsAllowed back into the running match.
A staff member with mineduels.proxy.bypass joins game-1 to check an arenaAllowed.
A player is told to spectate a player on game-1Allowed.

Bypass permission

Give staff the bypass with your permissions plugin:

/lp group staff permission set mineduels.proxy.bypass true

The proxy checks the permission when the player connects. The node can be renamed with gate.bypass-permission.

Velocity has no permission system of its own. Without a permissions plugin every player counts as having every permission. The proxy detects this, logs one error and trusts only gate.bypass-players:

gate.bypass-players=Notch,069a79f4-44e9-4726-a5be-fca90e38aaf5

The same list decides who may use /mdproxy drain and /mdproxy reload while no permissions plugin is installed.

Settings in config.properties

An older file gets this block at the end on the first start, and a copy is saved as config.properties.bak-before-gate. Your lines are not changed.

config-version=2
gate.enabled=true
gate.admit-seconds=90
gate.bypass-permission=mineduels.proxy.bypass
gate.bypass-players=
gate.extra-servers=
gate.on-redis-down=allow
drain.no-alternative=deny
KeyDefaultMeaning
gate.enabledtruefalse turns the gate off. Drain still works.
gate.admit-seconds90How long a player stays admitted after the match was assigned. Range 10 to 600.
gate.bypass-permissionmineduels.proxy.bypassThe node that skips the gate.
gate.bypass-playersemptyNames or UUIDs, comma separated. The only bypass without a permissions plugin.
gate.extra-serversemptyvelocity.toml server names to gate even though they send no heartbeat.
gate.on-redis-downallowallow opens the gate while this proxy hears nothing from Redis, so a Redis outage does not break matches. deny keeps it closed.
drain.no-alternativedenyA draining lobby with no other lobby to go to. deny shows a restart message, allow lets the player in.

Apply the gate settings without a restart:

/mdproxy reload

It reloads the gate keys, balance-first-join and webhook.yml. Redis, secret and region settings need a restart.

Examples

Gate two extra servers that never send heartbeats:

gate.extra-servers=practice,event-hub

Let a network stay open for staff only during testing:

gate.bypass-players=Alice,Bob
gate.on-redis-down=deny

Turn the gate off while you debug a transfer problem:

gate.enabled=false

A restart, step by step

Game server game-2:

  1. Run /md drain start update on game-2.
  2. The matchmaker stops choosing it within 2 seconds. Running matches finish.
  3. The webhook posts drain-empty after the server stayed empty for stable-seconds.
  4. Restart game-2 from the panel.

Proxy:

  1. Run /mdproxy drain start.
  2. New players use another proxy, or wait.
  3. The webhook posts proxy-empty when nobody is connected.
  4. Restart the proxy.

Things to know

  • The gate knows who may enter from the matches the lobbies assign. A player assigned a match is admitted by memory only, so the check never waits on Redis.
  • If the assignment message is lost, the player is sent to a lobby and the match is cancelled and requeued.
  • The proxy and the backends must run the same version. An older backend ignores the drain flag.

On this page