site serve: refuse to start on a port something else holds #253
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!253
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/site-serve-held-port"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
allod site servenow refuses to start a preview on a port that something else already holds. Before this it printed the other program's address and reported success.--stop,--vmandvieware untouched.Closes allod/tools#252
What changed
cmd/allod/site_serve.go: before starting a unit that is not running,serveconnects to127.0.0.1:<port>once. An answer isport <n> is already in use: <unit> was not started, exit 1, and nosystemd-run. The check comes after the checks of the checkout path and the flake'spreviewapp. The connection attempt is one function, shared with the wait that follows a start.docs/allod-site-preview.mdandserve --help: the contract no longer says a held port is reported "as serving", and the exit codes name a port in use.cmd/allod/site_serve_test.go: one new test. Four existing tests that start a unit now get their listener when the stubbedsystemd-runis called, where they used to open it beforehand, since a listener that is already there is now a port in use. Their assertions are unchanged.This replaces pull request allod/tools#251, closed unmerged. Picking a port for a site that has none was dropped; the reasoning is in the closing comment on allod/tools#249.
Risk
R2. One added refusal ahead of a start, in a command that starts a systemd unit.
servethen prints the address with exit 0 while the unit's journal shows the app failing.servecounts a unit as running whensystemctl is-activeexits 3, which covers a unit that has failed and not yet been cleared away. In that moment the check is skipped, and if another program holds the port, its address is printed. This was so before the change. Units are started with--collect, so the moment is brief. Closing it means changing what "running" means on every path, which is outside this issue.Validation
Run at
93450a6, the head of this branch, on a dev VM:go test ./...,go test -tags site ./...,go test -tags secret ./...,go test -tags site,secret ./..., each with-count=1: all seven packagesokin each of the four runs.go vet ./...andgofmt -l .: no output.allod check:All 11 steps passed (checks: 9 built).systemd-run ran 1 times, want 0.Run at
5966627, which differs from the head by one deleted comment line in a test file, against a throwaway site whose preview app islive-server:No unit existed after either. With the port free:
The page answered 200 and the listener was the unit's
live-server. A secondserveprinted the same address with one unit running.--stopexited 0. A site with no port was refused with today's message. Afterwards noallod-preview-*unit, nosocatand nolive-serverwas left.Not run: nothing from a second machine.
viewis not changed by this pull request.Review
One reviewer from another model family (
gpt-5.6-terra) read the diff cold at5966627.