Several servers
A site can run on more than one server. landfall deploys it to every server of a group, reads the group as one, and undoes a group deploy on every server.
Everything here is opt-in.
A .landfall.json without servers works exactly as before.
When you need it
One server is enough for most sites. Several servers keep a site up when one fails, and let you restart one server while the others serve. They cost more: you run more servers, and state (databases, uploads, sessions) has to live somewhere they all reach.
Words used here
| word | meaning |
|---|---|
| group | the servers a site runs on: servers in .landfall.json. The order counts. |
| primary | the first server of the group. The others are compared with it. Hooks that must run once will run there. |
| drift | the servers of a group differ: another release, another scale, another .env, or no site at all. |
Name the servers
List the servers in .landfall.json instead of server:
{
"name": "blog",
"servers": ["vps1", "vps2"],
"domains": ["blog.example.com"]
}- Each name must be a server landfall knows (
lf server add). - A name may appear once.
serverandserverstogether are refused. - An environment can set its own
serverorservers. Either one replaces the project's. lf deploy,lf history,lf undoand the site commands work on the whole group. See Change a group.
Pages
| page | what |
|---|---|
| Deploy to a group | one release to every server, what it refuses, services on the primary only, part of a group, certificates |
| Sync and drift | how landfall finds servers that differ, and lf sync to bring them back in line |
| An edge in front | one landfall server that holds the domains and spreads requests over the group |
| A private network | lf network: a WireGuard network between the servers and the edge |
| Groups in the web UI | the group view, the Edge card, and where a change goes |
Read a group
These commands read every server of the group at once.
Run them in the project folder, or name the servers with -s a,b.
# release, state and replicas on each server, and what differs
lf sites info blog
# the same as JSON (a GroupSiteView)
lf sites info blog -s vps1,vps2 --json
# the logs of every server, each line after its server's name
lf logs blog -n 50
# an HTTPS request to each server by its address, not by DNS
lf check blog- A server that does not answer within 15 seconds shows as unreachable. The others are not held up.
-s <one server>reads only that server, as before.lf checkon a group sends each request to the server's own address (as--resolve). It exits 1 when one fails.- A tenant login reads one server at a time. Group reads need each server's admin.
Change a group
The site commands run on every server of the group, one after the other.
Run them in the project folder, or name the servers with -s a,b.
# set a variable on every server
lf env blog API_URL=https://api.example.com
# three web containers on every server: six on two servers
lf scale blog web=3
# the previous release on every server
lf rollback blog| how | commands |
|---|---|
| every server; a failure puts the others back | env, secret, domains, auth, scale, weight, autoscale, rollback |
| every server; a failure stops | restart, stop, start, release rm, sites rm |
| every server at once, a block per server | ls, stats, disk, traffic, certs |
| the primary only | tunnel, open, eject, volumes, volume … |
| refused | adopt, autodeploy |
- One command is one run on every server.
lf undo <run id>reverts it on each one. - When a server fails, the change goes back on the servers before it and on the failed one. The error names the servers not tried.
restart,stop,sites rmand the others in that row leave the servers before a failed one as they are. They stop at the failed server and name the servers already done.sites rm,release rmanddomainsask once before they remove something. Every server is read first, and nothing changes until you answer. A server with nothing to remove is not asked.lf autoscale blogwithout rules reads every server: the rules, each server's count and the total.ls,stats,disk,trafficandcerts: a server that does not answer gets its error in its block. The others still show, and the command exits 1.--json,--pullandlf stats --watchread the primary. Pass-s <server>to read another.- Values read from stdin (
--dotenv -,--password-stdin) are read once and go to every server. -s <one server>changes that server only. landfall warns that the group drifts.- Without the project's
.landfall.json, a change on one server reads the server'ssite.json. If the site runs on several servers, landfall warns and names them. - Server commands (
firewall,users,keys,traefik,harden,updateand the like) work on one server. In a group's folder, they ask for it: pass-s <server>.
History and undo
Each server keeps its own journal and numbers its runs itself. A group deploy has one run id on every server.
# the runs of every server; a run on several servers is marked as a group run
lf history
# revert the newest group run on every server
lf undo
# revert a group run by its id, the primary last
lf undo mih3k2x1ab12
# one server's run #4
lf undo 4 -s vps2lf historyshows a server that does not answer asvps2: ?, and the runs of the others. With--json, that server has anerror.- A run number means nothing across servers. On a group,
lf undotakes a run id, or none for the newest group run. lf undo -s vps2reverts on that server only. landfall warns that the group drifts.- It checks every server before it changes one, then asks once.
- If a server fails, it stops and names the servers not reverted yet. Run the same
lf undoagain.
Limits
- Site commands change one server after the other. For a moment, the servers differ.
lf syncdoes not revert the servers it already changed when one fails. It names them.- Without an edge, every server serves the domains. Your DNS or load balancer decides which server a visitor reaches.
- The edge is one server. If it fails, the site is down: it is the single point of failure in front of the group.
- No groups for tenant logins.
- Volumes are not shared between servers.