internal/location probes an archive tree by one shell script run where it is, Local or over SSH, and a site by the version.json the build now writes; a Watcher probes every location at once every five minutes and keeps the last snapshot, which GET /status carries and the page tables. serve takes -nas, -tree and -site; task serve passes the Taskfile's LOCATIONS. archive.Parse reads archive.yaml's contents for Load and the probe. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
165 lines
7.8 KiB
YAML
165 lines
7.8 KiB
YAML
version: '3'
|
|
|
|
# .env (gitignored; see .env.example) may set BYTESTONE_ARCHIVE and BYTESTONE_ADDR.
|
|
dotenv: ['.env']
|
|
|
|
vars:
|
|
# The bytestone archive, on the NAS (docs/archive.md). PRODUCTION is the
|
|
# archive of record, written only by task promote; ARCHIVE is UAT, the
|
|
# staging copy every depositor writes and the site is built from (story
|
|
# 026), which the archive tasks work on.
|
|
NAS: humphrey@10.0.0.1
|
|
NAS_PORT: 5522
|
|
PRODUCTION: /volume1/H3Archive/bytestone
|
|
ARCHIVE: /volume1/H3Archive/bytestone-uat
|
|
# The archive the build and the service read: the laptop's mirror of UAT unless .env says otherwise.
|
|
MIRROR: '{{.BYTESTONE_ARCHIVE | default (printf "%s/.local/share/bytestone/uat" .HOME)}}'
|
|
# Where task serve listens.
|
|
ADDR: '{{if .BYTESTONE_ADDR}}-addr {{.BYTESTONE_ADDR}}{{end}}'
|
|
# What the status page probes (story 030): the trees on the NAS and the sites, UAT's and production's and www.bytestone.org.
|
|
LOCATIONS: -nas {{.NAS}}:{{.NAS_PORT}} -tree {{.PRODUCTION}} -tree {{.ARCHIVE}} -site https://i.bytestone.uk -site https://i.bytestone.org -site https://www.bytestone.org
|
|
RSYNC: rsync -az --chmod=D755,F644 -e "ssh -p {{.NAS_PORT}} -o BatchMode=yes"
|
|
# What the mirror leaves on the NAS.
|
|
BULK: --exclude items/ --exclude renditions/
|
|
# What promotion leaves alone: each instance keeps its own archive.yaml, and Synology's index directories stay where they are.
|
|
PROMOTE: --exclude archive.yaml --exclude @eaDir
|
|
|
|
tasks:
|
|
fmt:
|
|
desc: Format Go code
|
|
cmds:
|
|
- go fmt ./...
|
|
vet:
|
|
desc: Vet Go code, the page's wasm included
|
|
cmds:
|
|
- go vet ./...
|
|
- GOOS=js GOARCH=wasm go vet ./cmd/kinship
|
|
- go build ./cmd/...
|
|
lint:
|
|
desc: Run golangci-lint
|
|
cmds:
|
|
- golangci-lint run ./...
|
|
test:
|
|
desc: Run the tests
|
|
cmds:
|
|
- go test ./...
|
|
check:
|
|
desc: fmt, vet, lint, test
|
|
cmds:
|
|
- task: fmt
|
|
- task: vet
|
|
- task: lint
|
|
- task: test
|
|
perf:
|
|
desc: 'The search ladder: GET /people?q= at each scale of register (docs/stories/008-search-performance.md)'
|
|
cmds:
|
|
- go test -run '^$' -bench Search -benchmem ./internal/archive/
|
|
|
|
uat:seed:
|
|
desc: 'Seed UAT on the NAS from production, once: the whole tree copied, people and items, and its archive.yaml made UAT''s; refused when the UAT tree exists (story 026)'
|
|
cmds:
|
|
- |
|
|
ssh -p {{.NAS_PORT}} -o BatchMode=yes {{.NAS}} 'set -e
|
|
if [ -e {{.ARCHIVE}} ]; then echo "{{.ARCHIVE}} exists: UAT is seeded once, from production" >&2; exit 1; fi
|
|
cp -a {{.PRODUCTION}} {{.ARCHIVE}}
|
|
printf "name: bytestone-uat\npurpose: uat\nslot: 1\n" > {{.ARCHIVE}}/archive.yaml
|
|
cat {{.ARCHIVE}}/archive.yaml'
|
|
archive:pull:
|
|
desc: Mirror UAT from the NAS (archive.yaml, records and files; not items or renditions), the NAS winning
|
|
cmds:
|
|
- mkdir -p {{.MIRROR}}/people
|
|
- '{{.RSYNC}} {{.NAS}}:{{.ARCHIVE}}/archive.yaml {{.MIRROR}}/archive.yaml'
|
|
- '{{.RSYNC}} --delete {{.BULK}} {{.NAS}}:{{.ARCHIVE}}/people/ {{.MIRROR}}/people/'
|
|
archive:push:
|
|
desc: Send the mirror's archive.yaml and people tree to UAT on the NAS (adds and updates; never deletes there)
|
|
cmds:
|
|
- 'ssh -p {{.NAS_PORT}} {{.NAS}} mkdir -p {{.ARCHIVE}}/people'
|
|
- '{{.RSYNC}} {{.MIRROR}}/archive.yaml {{.NAS}}:{{.ARCHIVE}}/archive.yaml'
|
|
- '{{.RSYNC}} {{.BULK}} {{.MIRROR}}/people/ {{.NAS}}:{{.ARCHIVE}}/people/'
|
|
archive:diff:
|
|
desc: What archive:push would send
|
|
cmds:
|
|
- '{{.RSYNC}} -n -i {{.MIRROR}}/archive.yaml {{.NAS}}:{{.ARCHIVE}}/archive.yaml'
|
|
- '{{.RSYNC}} -n -i {{.BULK}} {{.MIRROR}}/people/ {{.NAS}}:{{.ARCHIVE}}/people/'
|
|
person:pull:
|
|
desc: 'Mirror one person entire, items and renditions included: task person:pull ID=0'
|
|
requires: {vars: [ID]}
|
|
vars:
|
|
DIR:
|
|
sh: go run ./cmd/life-weaver dir {{.ID}}
|
|
cmds:
|
|
- mkdir -p {{.MIRROR}}/people/{{.DIR}}
|
|
- '{{.RSYNC}} --delete {{.NAS}}:{{.ARCHIVE}}/people/{{.DIR}}/ {{.MIRROR}}/people/{{.DIR}}/'
|
|
person:push:
|
|
desc: 'Send one person entire to the NAS (adds and updates; never deletes there): task person:push ID=0'
|
|
requires: {vars: [ID]}
|
|
vars:
|
|
DIR:
|
|
sh: go run ./cmd/life-weaver dir {{.ID}}
|
|
cmds:
|
|
- 'ssh -p {{.NAS_PORT}} {{.NAS}} mkdir -p {{.ARCHIVE}}/people/{{.DIR}}'
|
|
- '{{.RSYNC}} {{.MIRROR}}/people/{{.DIR}}/ {{.NAS}}:{{.ARCHIVE}}/people/{{.DIR}}/'
|
|
|
|
build:
|
|
desc: Build the site from the mirror into site/, with the front page's wasm (search and kinship)
|
|
cmds:
|
|
- go run ./cmd/life-weaver build -archive {{.MIRROR}} -out site
|
|
- task: wasm
|
|
wasm:
|
|
desc: Compile the front page's Go (cmd/kinship) to site/kinship.wasm, with Go's wasm_exec.js
|
|
cmds:
|
|
- GOOS=js GOARCH=wasm go build -ldflags=-s -trimpath -o site/kinship.wasm ./cmd/kinship
|
|
- cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" site/
|
|
publish:
|
|
desc: 'Publish: the mirror → UAT on the NAS and back (archive:push, archive:pull), then build and send docs/ and site/ to their hosts (tp pages deploy): i.bytestone.uk is UAT; the stage-1 form of #41'
|
|
cmds:
|
|
- task: archive:push
|
|
- task: archive:pull
|
|
- task-plus pages deploy
|
|
promote:diff:
|
|
desc: What promote would change in production on the NAS (deletions included); nothing is written
|
|
cmds:
|
|
- ssh -p {{.NAS_PORT}} -o BatchMode=yes {{.NAS}} 'rsync -n -i -a --delete {{.PROMOTE}} {{.ARCHIVE}}/ {{.PRODUCTION}}/'
|
|
promote:
|
|
desc: 'Promote: production becomes what UAT is now. The UAT tree is copied over production''s on the NAS, people and items, deletions included (run promote:diff first), and i.bytestone.org becomes what i.bytestone.uk serves, a copy made on the host, no build (#103, story 026). The only task that writes production'
|
|
cmds:
|
|
- ssh -p {{.NAS_PORT}} -o BatchMode=yes {{.NAS}} 'rsync -a --delete {{.PROMOTE}} {{.ARCHIVE}}/ {{.PRODUCTION}}/'
|
|
- ssh -o BatchMode=yes deploy@docs.bytestone.uk 'rsync -a --delete /srv/sites/i/ /srv/sites/i-org/'
|
|
serve:
|
|
desc: 'Run the archive service over the archive (BYTESTONE_ARCHIVE, BYTESTONE_ADDR from .env): its API and its status page at /, which probes the NAS trees and the sites every 5 min; -buildvcs so it reports the release it runs'
|
|
cmds:
|
|
- go run -buildvcs=true ./cmd/life-weaver serve -archive {{.MIRROR}} {{.ADDR}} {{.LOCATIONS}}
|
|
fixity:
|
|
desc: 'Recompute every held item''s checksums from the archive on disk (the monthly fixity run): task fixity, or task fixity -- ITEM ...'
|
|
cmds:
|
|
- go run ./cmd/life-weaver fixity -archive {{.MIRROR}} {{.CLI_ARGS}}
|
|
preview:
|
|
desc: Serve site/ locally for preview
|
|
cmds:
|
|
- task-plus pages -site i
|
|
|
|
genealogy:demo:
|
|
desc: 'Draw the demo charts (the Drummond family from the mirror, or IDS="…") into charts/ and open the review page'
|
|
vars:
|
|
IDS: '{{.IDS | default "0 1 2 3 4 5 6"}}'
|
|
cmds:
|
|
- go run ./cmd/genealogy -archive {{.MIRROR}} -theme boxes,trellis,tendril,garland -out charts {{.IDS}}
|
|
- cmd: xdg-open charts/review.html
|
|
ignore_error: true
|
|
|
|
docs:build:
|
|
desc: Render the project docs into docs/
|
|
cmds:
|
|
- task-plus md2html --file index.md --dst docs
|
|
- task-plus md2html --file docs/archive.md --dst docs
|
|
- go run ./cmd/life-weaver brand docs/brand
|
|
- cp docs/brand/favicon.svg docs/favicon.svg
|
|
- task-plus md2html --file docs/brand.md --dst docs
|
|
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes,vine,trellis,tendril,garland -out docs/research/charts 0 3 7
|
|
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes -size full -out docs/research/charts/full 7
|
|
- go run ./cmd/genealogy -people internal/chart/testdata/people -theme boxes,vine -up 1 -down 1 -out docs/research/charts/near 3
|
|
- task-plus md2html --file research/charts.md --dst docs/research
|
|
clean:
|
|
desc: Remove build output
|
|
cmds:
|
|
- rm -rf site charts docs/*.html docs/research
|