site preview: support sites not built with zola, and start a preview in a VM from the hypervisor #234
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#234
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Make
allod site previewwork for a site that is not built with zola, and let the hypervisor start a preview inside a dev VM and reach it in one command.Primary goals:
allod site preview --vm <name>starts the preview in the VM and forwards every port the browser needs, and stopping it stops both.Current state and specifics
previewalways runs zola.cmd/allod/site_preview.go:40builds the one command line it can run:nix shell --inputs-from <root> nixpkgs#zola --command zola --root <root> serve. In a site repository with noconfig.tomlit exits with zola's own message:The comment at
cmd/allod/site_preview.go:14records the hardcoding as deliberate and names its own trigger: a second generator appearing in a site repository. Two have appeared, a bundled JavaScript application and a single hand-written HTML page. Both publish correctly withallod site deploy, which builds the repository's default flake package and never asks what produced the files.The flags at
cmd/allod/site_preview.go:58and:64mirror zola's own.--portand--interfacemean something to any server;--base-urland--draftsare zola's alone.How a preview is chosen
In this order, stopping at the first that applies:
previewnix runconfig.tomlexistsalloditselfThe third row needs no generator and no extra dependency: the files are already what deploy would publish. It has no live reload, which is acceptable for a site with no development server to reload from.
A
previewapp needs to be told where to listen. The default is two environment variables set byallod, one for the port and one for the interface, so the app's own command line stays its own.--base-urland--draftskeep working for zola and are refused, by name, for the other two rows.Measured on a dev VM
Zola 0.21.0, started by
allod site preview --port 1188with standard input closed and no terminal attached:touch1024for live reload. The page loads/livereload.js?port=1024allodprocess aloneallodexits, zola keeps running and keeps the portlocalhostresolves to::1onlyThree consequences for the design:
alloddoes not take its child down with it. A session that ends without a terminal hangup leaves the server behind, and the next preview cannot bind.localhostby default listens on IPv6 loopback only, and a forward aimed at127.0.0.1misses it. The interface the tool passes is the literal127.0.0.1.Starting it from the hypervisor
Dev VMs cannot open a connection to the hypervisor, so the forward is opened from the hypervisor side.
allod site preview --vm <name>, run there inside a site checkout, connects to the VM, runsallod site previewin the same checkout path, and forwards the ports over that one connection.Two properties of the connection are load-bearing:
The VM's firewall stays closed. Nothing listens on any address but loopback, on either machine.
Validation
--draftswith a message that names the flag.allod site previewis interrupted, and after its parent is killed, no child process remains and the port is free.--vmserves the page, a saved edit in the VM reloads the browser without a refresh, and after an interrupt both machines show the ports free. Repeated with the network connection dropped instead of interrupted.Scope
In scope: generator selection in
preview, the static fallback, process cleanup,--vm, and the help text and tests for each.Out of scope:
deploy,checkandconfig, which are already independent of the generator. Moving site repositories onto a shared site builder is separate work. Choosing a free port automatically when the default is taken is a follow-up; the first version refuses with a message that names the port.Results of the manual test, run from a hypervisor against a dev VM with a zola site. Each run started
allod site previewin the VM over SSH with both ports forwarded, then was interrupted with Ctrl-C.-t)In every run the tools were found on the non-interactive session's PATH, the site built and served, and a saved edit in the VM triggered a rebuild.
What this settles:
One log line worth keeping: after the server was stopped, the VM's SSH daemon recorded
connect_to 127.0.0.1 port 1024: failedfour times in three seconds. That is the browser retrying the live reload port through a forward that no longer had anything behind it, and it confirms that zola's reload channel travels on the second port.Not tested: a dropped network connection in place of an interrupt, and whether the browser reloaded without a manual refresh.
Closed unfinished and replaced by allod/tools#240. This issue's design is not being carried forward; it is left as written so the record shows what was tried.
What this issue asked for, and what happened
It asked for three ways to serve a site chosen by what the repository contains, zola kept exactly as it was, cleanup of the server process, and
--vmto start a preview in a VM and forward its ports. allod/tools#236 built all of it in about 2,200 lines, passed its tests and a cold review, and was closed unmerged when the owner read it. The reasons are recorded on that pull request.What was wrong with the design here
What stays true
The measurements in this issue and its comment stand and are carried into allod/tools#240: zola 0.21 listens on a second port,
localhostresolves to::1only, a server signalled through its parent alone keeps running, and a forward on a shared connection outlives the command that asked for it.Closed as not planned.