Registries
Redis
Servers add themselves to a Redis you run and report their player counts every few seconds.
With "backend": "redis", every server writes itself into a Redis database and
reads everyone else from it. New servers appear by themselves, and /play sees
real player counts.
{
"serverId": "sw-1",
"group": "skywars",
"host": "play.example.com",
"port": 5521,
"backend": "redis",
"redis": {
"url": "redis://:your-password@10.0.0.5:6379/0",
"namespace": "link"
}
}Set it up
- Make sure every server can reach your Redis, and that the Redis has a password.
- Put the
redisblock inlink.jsonon every server, with its ownserverId,group,hostandport. - Start the servers. The first one to connect creates the network secret in Redis. The others read it, so there is nothing to copy.
host is required with Redis. It is the address players are sent to, so it must
be reachable from a player’s game.
Put a password on that Redis. Anyone who can write to it can add a server to your network and sign transfers. Use
rediss://in the URL for TLS.
How it works
- Every 3 seconds, each server writes its current player count and reads the list.
- Each server’s entry expires 15 seconds after its last write, so a server that crashes drops out of
/playby itself. - A server that shuts down cleanly removes itself right away.
Link uses these keys, under your namespace:
| Key | Holds |
|---|---|
link:secret | The network secret, created by the first server |
link:servers | The ids of every server that has registered |
link:server:<id> | That server’s details, expiring with its heartbeat |
Several networks, one Redis
Give each network its own namespace. Networks with different namespaces don’t
see each other and have different secrets.