Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 706d22ab78 | |||
| 5d408a4ee3 | |||
| 0e90fd819a | |||
| 7a4cf199c2 |
@@ -58,6 +58,13 @@
|
||||
# This workflow still never writes to a branch. It tags and publishes, so `main`
|
||||
# needs no push exception.
|
||||
#
|
||||
# ── And then the uom site ────────────────────────────────────────────────────
|
||||
#
|
||||
# A published release is rolled onto the uom site by the `deploy-uom` job at the
|
||||
# bottom, the module's twin of `website`'s `build-images.yml` deploy. Dispatching
|
||||
# with `redeploy = true` publishes nothing and rolls the newest release out
|
||||
# again — for a deploy that was skipped because the site's core was too old.
|
||||
#
|
||||
# Prerequisites (Settings → Actions → Secrets on RunicGateway/Module-uo):
|
||||
# REGISTRY_TOKEN — Gitea access token with `write:repository`, to push the tag
|
||||
# and create the release.
|
||||
@@ -77,6 +84,10 @@ on:
|
||||
description: 'Bump level when version is blank: patch | minor | major'
|
||||
required: false
|
||||
default: 'patch'
|
||||
redeploy:
|
||||
description: 'true = publish nothing; just roll the uom site onto the newest release'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
concurrency:
|
||||
group: release-module-uo
|
||||
@@ -90,6 +101,10 @@ jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
# Read by `deploy-uom` below: whether there is something to roll out, and which.
|
||||
outputs:
|
||||
deploy: ${{ steps.plan.outputs.deploy }}
|
||||
version: ${{ steps.plan.outputs.version }}
|
||||
steps:
|
||||
# Full history: the plan step reads every tag and every subject since the
|
||||
# newest one, and a shallow clone has neither.
|
||||
@@ -108,6 +123,7 @@ jobs:
|
||||
EVENT: ${{ github.event_name }}
|
||||
IN_VERSION: ${{ github.event.inputs.version }}
|
||||
IN_BUMP: ${{ github.event.inputs.bump }}
|
||||
IN_REDEPLOY: ${{ github.event.inputs.redeploy }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p dist
|
||||
@@ -119,6 +135,27 @@ jobs:
|
||||
RANGE="${LAST_TAG:+${LAST_TAG}..}HEAD"
|
||||
echo "module.json declares ${DECLARED}; newest tag is ${LAST_TAG:-<none>}"
|
||||
|
||||
# The redeploy button: publish nothing, hand the newest tag to
|
||||
# `deploy-uom`. For a deploy that was skipped (core too old) or failed,
|
||||
# once whatever stopped it is fixed — a plain re-run of the workflow
|
||||
# would find that version already released and deploy nothing.
|
||||
if [ "${EVENT:-}" = workflow_dispatch ] && [ "${IN_REDEPLOY:-false}" = true ]; then
|
||||
if [ -z "$CURRENT" ]; then
|
||||
echo "::error::Redeploy asked for, but there is no release to deploy."
|
||||
exit 1
|
||||
fi
|
||||
echo "dispatch: redeploying ${LAST_TAG} to the uom site, publishing nothing"
|
||||
{
|
||||
echo "version=${CURRENT}"
|
||||
echo "tag=${LAST_TAG}"
|
||||
echo "release=false"
|
||||
echo "reuse_tag=false"
|
||||
echo "bump=none"
|
||||
echo "deploy=true"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SUBJECTS="$(git log --no-merges --format='%s' $RANGE || true)"
|
||||
BODIES="$(git log --no-merges --format='%B' $RANGE || true)"
|
||||
|
||||
@@ -263,6 +300,7 @@ jobs:
|
||||
echo "release=${RELEASE}" >> "$GITHUB_OUTPUT"
|
||||
echo "reuse_tag=${REUSE_TAG}" >> "$GITHUB_OUTPUT"
|
||||
echo "bump=${BUMP}" >> "$GITHUB_OUTPUT"
|
||||
echo "deploy=${RELEASE}" >> "$GITHUB_OUTPUT"
|
||||
echo "==> release=${RELEASE} version=${VERSION} bump=${BUMP} declared=${DECLARED} last_tag=${LAST_TAG:-<none>}"
|
||||
|
||||
# Before anything is built or tagged, so a repo without secrets fails
|
||||
@@ -442,3 +480,211 @@ jobs:
|
||||
-F "attachment=@dist/${f}" >/dev/null
|
||||
echo " uploaded ${f}"
|
||||
done
|
||||
|
||||
# ── Roll the uom site onto the release ────────────────────────────────────
|
||||
#
|
||||
# The website's own `build-images.yml` rolls the uom site onto every new core
|
||||
# image from this same runner; this does the same for the uo module. It does
|
||||
# not unpack anything itself: it points the site's MODULES declaration at the
|
||||
# new release and recreates the app container, and core's own start-up
|
||||
# (website `server/src/modules/declared.js`) fetches it, verifies the sha256 in
|
||||
# the manifest and unpacks it — the path every operator's install takes.
|
||||
#
|
||||
# 1. Ask the RUNNING core whether it can load this release (the manifest's
|
||||
# coreApi against its MODULE_API_VERSION). If not, warn and change
|
||||
# nothing: the version already there keeps running until the site's core
|
||||
# catches up, and then the Redeploy button (Run workflow, redeploy = true)
|
||||
# rolls it out.
|
||||
# 2. Rewrite the `uo@…` entry of the MODULES line in .env, in place (other
|
||||
# entries and every other line are kept; the file keeps its owner and
|
||||
# mode). No MODULES line yet, as on a site where uo was installed from
|
||||
# Admin → Modules, appends one. Only id@version is ever printed — this
|
||||
# file holds the site's secrets.
|
||||
# 3. Recreate only the app container (not the db, not the bot) and wait for
|
||||
# core to log `registered module "uo" v<version>`.
|
||||
# 4. If it does not, put the entry back to the version that was running and
|
||||
# recreate again, so a bad release leaves the site where it was, and fail
|
||||
# the job either way.
|
||||
#
|
||||
# `needs: release` with the job's own `deploy` output: only a run that
|
||||
# published a release (or a redeploy dispatch) gets here, and only after its
|
||||
# assets are uploaded.
|
||||
#
|
||||
# Runner: `uom-deploy-runner`, the one `website`'s deploy job uses, on the
|
||||
# production host. It needs Docker Compose and write access to the site's
|
||||
# .env. The site directory defaults to the one `website`'s deploy job uses;
|
||||
# set the Actions variable UOM_SITE_DIR to move it.
|
||||
deploy-uom:
|
||||
needs: release
|
||||
if: needs.release.outputs.deploy == 'true' && github.ref == 'refs/heads/main'
|
||||
runs-on: uom-deploy-runner
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
SITE_DIR: ${{ vars.UOM_SITE_DIR || '/home/perry/website' }}
|
||||
VERSION: ${{ needs.release.outputs.version }}
|
||||
steps:
|
||||
- name: Check the running core, declare the release, restart the app
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
cd "$SITE_DIR"
|
||||
|
||||
manifest() { echo "https://${GITEA_HOST}/${REPO}/releases/download/v$1/module-uo-$1.json"; }
|
||||
NEW="uo@${VERSION}=$(manifest "$VERSION")"
|
||||
|
||||
test -f .env || { echo "::error::${SITE_DIR}/.env is missing."; exit 1; }
|
||||
test -w .env || { echo "::error::The runner cannot write ${SITE_DIR}/.env."; exit 1; }
|
||||
COUNT="$(grep -cE '^[[:space:]]*MODULES[[:space:]]*=' .env || true)"
|
||||
if [ "${COUNT:-0}" -gt 1 ]; then
|
||||
echo "::error::.env sets MODULES ${COUNT} times. Leave one line, then press Redeploy."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── 1. Can the running core load it? ─────────────────────────────
|
||||
# Asked inside the app container: it has core's own version and range
|
||||
# check, and the network path core itself will use to fetch the bundle.
|
||||
# Prints one line: `ok|skip <core API> <uo version now> <coreApi range>`.
|
||||
if ! CHECK="$(docker compose exec -T app node -e '
|
||||
const [url, want] = process.argv.slice(1)
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { satisfies } = require("/app/server/src/modules/semver")
|
||||
const { MODULE_API_VERSION: core } = require("/app/server/src/modules/version")
|
||||
let prev = "none"
|
||||
try {
|
||||
const dir = process.env.MODULES_DIR || "/app/modules"
|
||||
prev = JSON.parse(fs.readFileSync(path.join(dir, "uo", "module.json"), "utf8")).version || "none"
|
||||
} catch {}
|
||||
fetch(url).then(async (r) => {
|
||||
if (!r.ok) throw new Error(`the manifest answered HTTP ${r.status}`)
|
||||
const m = await r.json()
|
||||
if (m.id !== "uo" || m.version !== want) throw new Error(`the manifest is ${m.id}@${m.version}, not uo@${want}`)
|
||||
console.log(`${satisfies(core, m.coreApi) ? "ok" : "skip"} ${core} ${prev} ${m.coreApi}`)
|
||||
}).catch((e) => { console.log(`error ${e.message}`); process.exit(1) })
|
||||
' "$(manifest "$VERSION")" "$VERSION")"; then
|
||||
echo "::error::Could not check the running site: ${CHECK:-the app container did not answer (is it running?)}"
|
||||
exit 1
|
||||
fi
|
||||
read -r VERDICT CORE PREV RANGE <<< "$CHECK"
|
||||
echo "uom site: core API ${CORE}, uo ${PREV} on the volume; release v${VERSION} needs ${RANGE}"
|
||||
|
||||
if [ "$VERDICT" = skip ]; then
|
||||
echo "::warning::uo v${VERSION} needs core API ${RANGE} and the uom site runs ${CORE}. Nothing changed; uo ${PREV} keeps running. Once the site's core is updated, run Release with redeploy = true."
|
||||
exit 0
|
||||
fi
|
||||
if [ "$PREV" = "$VERSION" ] && grep -qF "$NEW" .env; then
|
||||
echo "uo v${VERSION} is already declared and on the volume. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# MODULES set under `environment:` in docker-compose.yml wins over .env,
|
||||
# so editing .env would change nothing. Catch it before touching anything.
|
||||
ENV_MODULES="$(docker compose exec -T app printenv MODULES 2>/dev/null || true)"
|
||||
if [ -n "$ENV_MODULES" ] && [ "${COUNT:-0}" -eq 0 ]; then
|
||||
echo "::error::The app has MODULES set but .env has no MODULES line, so it comes from docker-compose.yml's environment:, which wins over .env. Move it into .env, then press Redeploy."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Core logs `registered module` at info. With a quieter LOG_LEVEL that
|
||||
# line never reaches `docker compose logs`, so success is judged by the
|
||||
# volume instead (failures are logged at error and still show).
|
||||
LOG_LEVEL_NOW="$(docker compose exec -T app printenv LOG_LEVEL 2>/dev/null || true)"
|
||||
case "$(echo "${LOG_LEVEL_NOW:-info}" | tr '[:upper:]' '[:lower:]')" in
|
||||
warn|error) QUIET=true; echo "The app runs with LOG_LEVEL=${LOG_LEVEL_NOW}; checking the volume rather than the info log." ;;
|
||||
*) QUIET=false ;;
|
||||
esac
|
||||
|
||||
# ── 2. Point MODULES at it ───────────────────────────────────────
|
||||
ORIG="$(mktemp)"; TMP="$(mktemp)"
|
||||
trap 'rm -f "$ORIG" "$TMP"' EXIT
|
||||
cat .env > "$ORIG"
|
||||
|
||||
# Rewrites the uo entry of the original file's MODULES line (or appends
|
||||
# the line), then writes the result over .env in place with `cat >`, so
|
||||
# the file keeps its inode, owner and mode. If that write does not land
|
||||
# intact (a full disk), the original goes back before the job fails.
|
||||
# Plain `[ \t]`, not `[[:space:]]`: older mawk, Ubuntu's default awk,
|
||||
# has no character classes in regex literals.
|
||||
set_entry() {
|
||||
awk -v entry="$1" -v sq="'" '
|
||||
/^[ \t]*MODULES[ \t]*=/ {
|
||||
v = $0
|
||||
sub(/^[ \t]*MODULES[ \t]*=[ \t]*/, "", v)
|
||||
sub(/[ \t]+#.*$/, "", v)
|
||||
gsub(/"/, "", v); gsub(sq, "", v)
|
||||
n = split(v, parts, /[, \t]+/)
|
||||
out = ""
|
||||
for (i = 1; i <= n; i++) if (parts[i] != "" && parts[i] !~ /^uo@/) out = out parts[i] ","
|
||||
print "MODULES=" out entry
|
||||
found = 1
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
END { if (!found) print "MODULES=" entry }
|
||||
' "$ORIG" > "$TMP"
|
||||
test -s "$TMP" || { echo "::error::Rewriting .env produced an empty file; .env left as it was."; exit 1; }
|
||||
if ! { cat "$TMP" > .env && cmp -s "$TMP" .env; }; then
|
||||
cat "$ORIG" > .env || true
|
||||
echo "::error::Writing .env failed; the original was put back. Nothing was restarted by this step."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# id@version of each declared entry — never the URLs, never the rest of the file.
|
||||
declared() {
|
||||
local d
|
||||
d="$(grep -E '^[[:space:]]*MODULES[[:space:]]*=' "$1" \
|
||||
| grep -oE '[A-Za-z0-9_.-]+@[^=[:space:],]+=' | tr -d '=' | paste -sd' ' - || true)"
|
||||
echo "${d:-(none)}"
|
||||
}
|
||||
|
||||
# ── 3. Recreate the app and wait for core to say so ─────────────
|
||||
# Only uo's own lines and MODULES errors are ever printed from the app log.
|
||||
uo_lines() { grep -E 'module "uo"|declared module "uo|MODULES' <<< "$1" | tail -n 20 || true; }
|
||||
restart_and_wait() {
|
||||
local want="$1" since logs on_volume settled=0
|
||||
since="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
docker compose up -d --no-deps --force-recreate app
|
||||
for _ in $(seq 1 60); do
|
||||
sleep 5
|
||||
logs="$(docker compose logs --no-color --since "$since" app 2>&1 || true)"
|
||||
if grep -qE 'could not resolve declared module "uo@|module "uo" (failed to|was not started)|MODULES: ' <<< "$logs"; then
|
||||
uo_lines "$logs"
|
||||
return 1
|
||||
fi
|
||||
# Anchored after the version, so v1.2.1 is not satisfied by v1.2.10.
|
||||
if grep -qE "registered module \"uo\" v${want//./\\.}([^0-9A-Za-z.+-]|\$)" <<< "$logs"; then return 0; fi
|
||||
if [ "$QUIET" = true ]; then
|
||||
on_volume="$(docker compose exec -T app node -p 'require((process.env.MODULES_DIR || "/app/modules") + "/uo/module.json").version' 2>/dev/null || true)"
|
||||
# The load fails, if it fails, right after the unpack. Give it
|
||||
# three quiet polls on the new version before calling it good.
|
||||
if [ "$on_volume" = "$want" ]; then settled=$((settled + 1)); else settled=0; fi
|
||||
if [ "$settled" -ge 3 ]; then return 0; fi
|
||||
fi
|
||||
done
|
||||
echo "No word from the app about uo v${want} after 5 minutes. Its uo lines:"
|
||||
uo_lines "$logs"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "MODULES before: $(declared "$ORIG")"
|
||||
set_entry "$NEW"
|
||||
echo "MODULES after: $(declared .env)"
|
||||
if restart_and_wait "$VERSION"; then
|
||||
echo "uo v${VERSION} is registered on the uom site."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ── 4. It did not come up: put back what was running ─────────────
|
||||
if [ "$PREV" = none ]; then
|
||||
echo "::error::uo v${VERSION} did not come up, and there was no earlier uo to roll back to."
|
||||
exit 1
|
||||
fi
|
||||
echo "Rolling the uom site back to uo v${PREV}."
|
||||
set_entry "uo@${PREV}=$(manifest "$PREV")"
|
||||
echo "MODULES now: $(declared .env)"
|
||||
if restart_and_wait "$PREV"; then
|
||||
echo "::error::uo v${VERSION} did not come up on the uom site. Rolled back to v${PREV}, which is running."
|
||||
else
|
||||
echo "::error::uo v${VERSION} did not come up, and neither did the rollback to v${PREV}. The site is up without uo; see Admin → Modules."
|
||||
fi
|
||||
exit 1
|
||||
|
||||
11
README.md
11
README.md
@@ -158,6 +158,17 @@ For a change with nothing releasable behind it — a widened `coreApi`, a new mo
|
||||
run the **Release** workflow by hand (Actions → Release → Run workflow). Leave `version` blank to
|
||||
bump the newest tag by `bump` (default `patch`), or type an exact version to publish that.
|
||||
|
||||
**Every release then rolls onto the uom site** — the `deploy-uom` job, the module's twin of the
|
||||
website's own deploy, on the same `uom-deploy-runner`. It asks the running core whether it can load
|
||||
the release (`coreApi` against `MODULE_API_VERSION`); if it cannot, it warns and changes nothing.
|
||||
Otherwise it rewrites the `uo@…` entry of the `MODULES` line in the site's `.env` (appending the line
|
||||
if there is none; other entries are kept), recreates only the app container, and waits for core to
|
||||
log `registered module "uo" v<version>`. If that does not come, it declares the version that was
|
||||
running before, recreates again, and fails. **Run workflow** with `redeploy = true` publishes nothing
|
||||
and rolls the newest release out again — for a deploy that was skipped until the site's core caught
|
||||
up. The site directory defaults to `/home/perry/website`; the Actions variable `UOM_SITE_DIR`
|
||||
overrides it.
|
||||
|
||||
Each release carries:
|
||||
|
||||
| Asset | What it is |
|
||||
|
||||
@@ -26,8 +26,8 @@ import { CreaturePortrait } from '../public/Atlas.jsx'
|
||||
// for.
|
||||
//
|
||||
// **Nothing on this page throws for an operator-visible problem.** A shard that
|
||||
// is down, an asset plane switched off, a Linux host with no libgdiplus, a client
|
||||
// with no cliloc file — each is a reported state with a reason naming what to
|
||||
// is down, an asset plane switched off, a client with no cliloc file — each is a
|
||||
// reported state with a reason naming what to
|
||||
// fix. A red box that says "500" would be the one thing an operator cannot act
|
||||
// on, and every one of these states is ordinary.
|
||||
|
||||
@@ -332,7 +332,6 @@ export default function ClientFiles() {
|
||||
// want opposite things from this page: one needs its buttons disabled, the
|
||||
// other needs them available so the operator can retry.
|
||||
const linked = Boolean(assets?.linked)
|
||||
const imagingBroken = shard?.imaging && shard.imaging.ok === false
|
||||
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
|
||||
@@ -394,21 +393,6 @@ export default function ClientFiles() {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{imagingBroken && (
|
||||
<section
|
||||
style={{ border: '1px solid #c58f4a', borderRadius: 10, padding: 16, background: 'rgba(197,143,74,0.08)' }}
|
||||
className="sans"
|
||||
>
|
||||
<strong style={{ color: 'var(--head)' }}>The shard host cannot render images.</strong>
|
||||
<p style={{ margin: '6px 0 0', color: 'var(--muted)', fontSize: '0.86rem', lineHeight: 1.6 }}>
|
||||
{shard.imaging.reason ||
|
||||
'A Linux shard host needs libgdiplus before it can decode a single sprite.'}{' '}
|
||||
Names (the cliloc table) are unaffected and can still be imported — they have no pixels
|
||||
in them.
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{review.assets && (
|
||||
<VanishedReview
|
||||
review={review.assets}
|
||||
|
||||
@@ -166,7 +166,7 @@ function removeSprite(name) {
|
||||
* operator can read it:
|
||||
*
|
||||
* `skipped` no shard configured — the file era had no equivalent here
|
||||
* `unavailable` the shard could not answer (down, plane off, no libgdiplus)
|
||||
* `unavailable` the shard could not answer (down, plane off)
|
||||
* `unchanged` the client files match what was imported; nothing fetched
|
||||
* `imported` fetched and applied
|
||||
* `needsReview` a key we hold has vanished from the shard's manifest
|
||||
@@ -197,17 +197,6 @@ async function importAssets({ force = false, approve = false, by = null } = {})
|
||||
return failure(err, 'client file manifest')
|
||||
}
|
||||
|
||||
// §4.4: a Linux shard host without libgdiplus cannot render a sprite at all.
|
||||
// It is reported on the source gate precisely so an operator meets it while
|
||||
// setting the shard up rather than from an empty bestiary weeks later.
|
||||
if (sources.imaging && sources.imaging.ok === false) {
|
||||
return {
|
||||
status: 'unavailable',
|
||||
code: 'NO_IMAGING',
|
||||
reason: sources.imaging.reason || 'the shard host cannot render images',
|
||||
}
|
||||
}
|
||||
|
||||
const meta = await db.getMeta().catch(() => null)
|
||||
|
||||
if (!force && bridge.sameSources(sources, meta?.sources)) {
|
||||
@@ -561,7 +550,6 @@ async function getStatus() {
|
||||
extractorVersion: sources.extractorVersion,
|
||||
hashing: sources.hashing,
|
||||
complete: sources.complete,
|
||||
imaging: sources.imaging,
|
||||
// Which §5 families this overlay serves. A phase-3 or phase-4 overlay says
|
||||
// `['body']`, which is what an admin panel needs in order to say "update
|
||||
// your plugin" rather than showing an item-art pipeline that cannot work.
|
||||
|
||||
@@ -288,14 +288,6 @@ async function warm({ limit = WARM_BATCH, force = false } = {}) {
|
||||
return failure(err, 'client file manifest')
|
||||
}
|
||||
|
||||
if (sources.imaging && sources.imaging.ok === false) {
|
||||
return {
|
||||
status: 'unavailable',
|
||||
code: 'NO_IMAGING',
|
||||
reason: sources.imaging.reason || 'the shard host cannot render images',
|
||||
}
|
||||
}
|
||||
|
||||
// A phase-3 or phase-4 overlay serves bodies and nothing else. Asking it for a
|
||||
// static is refused per request, which would be a warn on every pass forever —
|
||||
// so it is checked once, here, and reported as the ordinary state it is.
|
||||
|
||||
@@ -377,7 +377,7 @@ shardRouter.get(
|
||||
'/assets',
|
||||
// #swagger.tags = ['Admin · Shard']
|
||||
// #swagger.summary = 'Client asset import status: what is loaded, what the shard has, whether they differ (admin only)'
|
||||
// #swagger.description = 'What the site currently holds (the imported body catalogue, how many sprites are stored, how many atlas creatures resolved to a body id) beside what the shard reports for the client files those pictures come from. `drift: true` means the client files have changed since the last import — press Import. `shard.hashing: true` means a null hash is “not computed yet”, not “changed”: the shard hashes 195 MB anim files off the request path. `shard.imaging.ok: false` is the named NO_IMAGING state — a Linux shard host without libgdiplus cannot render a sprite at all, and the reason names the package to install. A shard with no link configured, or one that is down, is a reported state with a reason rather than an error.'
|
||||
// #swagger.description = 'What the site currently holds (the imported body catalogue, how many sprites are stored, how many atlas creatures resolved to a body id) beside what the shard reports for the client files those pictures come from. `drift: true` means the client files have changed since the last import — press Import. `shard.hashing: true` means a null hash is “not computed yet”, not “changed”: the shard hashes 195 MB anim files off the request path. A shard with no link configured, or one that is down, is a reported state with a reason rather than an error.'
|
||||
// #swagger.security = [{ "cookieAuth": [] }, { "bearerAuth": [] }]
|
||||
/* #swagger.responses[200] = { description: 'Asset import status', content: { "application/json": { schema: { $ref: "#/components/schemas/UoAssetStatus" } } } } */
|
||||
/* #swagger.responses[403] = { description: 'Admin role required', content: { "application/json": { schema: { $ref: "#/components/schemas/Error" } } } } */
|
||||
@@ -403,7 +403,7 @@ shardRouter.post(
|
||||
'/assets/warm',
|
||||
// #swagger.tags = ['Admin · Shard']
|
||||
// #swagger.summary = 'Fetch item and land artwork the site is missing, now (admin only)'
|
||||
// #swagger.description = 'Runs one pass of the item-art warm loop instead of waiting for its timer. The pass works out which item pictures this site's own rows name — every distinct (ItemID, hue) on a player vendor, plus anything a character sheet has shown since the last pass — and fetches the ones it does not already hold from the shard, hued and stored under uploads/items/. There is deliberately NO manifest and no bulk import here: the client addresses 49,152 item graphics times three thousand hues, so the working set is defined by what the site actually displays. `force` re-fetches pictures the site already holds, which is how an operator recovers a wiped uploads volume. `limit` bounds one pass; the default is 400, because the shard serves one asset request at a time and a pass must not hold that slot against an import. Nothing throws for an operator-visible problem: no shard configured, a shard that is down, an asset plane switched off, a host with no libgdiplus, or a plugin overlay too old to serve item art all answer 200 with status "unavailable"/"skipped" and a reason naming what to fix.'
|
||||
// #swagger.description = 'Runs one pass of the item-art warm loop instead of waiting for its timer. The pass works out which item pictures this site's own rows name — every distinct (ItemID, hue) on a player vendor, plus anything a character sheet has shown since the last pass — and fetches the ones it does not already hold from the shard, hued and stored under uploads/items/. There is deliberately NO manifest and no bulk import here: the client addresses 49,152 item graphics times three thousand hues, so the working set is defined by what the site actually displays. `force` re-fetches pictures the site already holds, which is how an operator recovers a wiped uploads volume. `limit` bounds one pass; the default is 400, because the shard serves one asset request at a time and a pass must not hold that slot against an import. Nothing throws for an operator-visible problem: no shard configured, a shard that is down, an asset plane switched off, or a plugin overlay too old to serve item art all answer 200 with status "unavailable"/"skipped" and a reason naming what to fix.'
|
||||
// #swagger.security = [{ "cookieAuth": [] }, { "bearerAuth": [] }]
|
||||
/* #swagger.requestBody = { required: false, content: { "application/json": { schema: { type: "object", properties: { force: { type: "boolean", description: "Re-fetch pictures this site already holds." }, limit: { type: "integer", description: "How many keys this pass may fetch (1-2000)." } } } } } } */
|
||||
/* #swagger.responses[200] = { description: 'What the pass did', content: { "application/json": { schema: { $ref: "#/components/schemas/UoItemArtWarmResult" } } } } */
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
// records the action in the admin activity log.
|
||||
//
|
||||
// **An import result is not an exception**, exactly as for clilocs. A shard that
|
||||
// is down, an asset plane the operator has switched off, a Linux host with no
|
||||
// libgdiplus, a client patched halfway through the walk — each is a 200 carrying
|
||||
// is down, an asset plane the operator has switched off, a client patched
|
||||
// halfway through the walk — each is a 200 carrying
|
||||
// `status: 'unavailable'` and a reason naming what to fix, not a 500 that says
|
||||
// only "something broke". The one thing that DOES 500 is this file having a bug.
|
||||
//
|
||||
|
||||
@@ -684,16 +684,6 @@ module.exports = {
|
||||
extractorVersion: { type: 'integer', example: 1 },
|
||||
hashing: { type: 'boolean', description: 'A hash is being computed in the background. A null `sha256` while this is true means “not yet”, never “changed”.', example: false },
|
||||
complete: { type: 'boolean', description: 'Every client file has a content hash.', example: true },
|
||||
imaging: {
|
||||
type: 'object',
|
||||
nullable: true,
|
||||
description: 'Whether the shard host can render an image at all. `ok: false` is the named NO_IMAGING state: ServUO under Mono needs libgdiplus, and without it a Linux shard cannot decode a sprite. Cliloc and atlas import are unaffected.',
|
||||
properties: {
|
||||
ok: { type: 'boolean', example: true },
|
||||
code: { type: 'string', nullable: true, example: null },
|
||||
reason: { type: 'string', nullable: true },
|
||||
},
|
||||
},
|
||||
families: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
@@ -713,14 +703,14 @@ module.exports = {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
description: 'Machine-readable cause of `reason`.',
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'NO_IMAGING', 'SOURCE_CHANGED', 'UNAVAILABLE'],
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'SOURCE_CHANGED', 'UNAVAILABLE'],
|
||||
},
|
||||
},
|
||||
},
|
||||
UoAssetImportResult: {
|
||||
type: 'object',
|
||||
description:
|
||||
'Outcome of an asset import. Reported rather than thrown, so a shard that is down or a host that cannot render images is an answer and not a 500.',
|
||||
'Outcome of an asset import. Reported rather than thrown, so a shard that is down is an answer and not a 500.',
|
||||
properties: {
|
||||
status: {
|
||||
type: 'string',
|
||||
@@ -732,8 +722,8 @@ module.exports = {
|
||||
code: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
description: 'Machine-readable cause. `NO_IMAGING` is a shard host with no libgdiplus; `SOURCE_CHANGED` is a client patched partway through the walk, in which case nothing was applied.',
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'NO_IMAGING', 'SOURCE_CHANGED', 'INCOMPLETE', 'STUCK', 'MALFORMED', 'TOO_LARGE', 'UNAVAILABLE'],
|
||||
description: 'Machine-readable cause. `SOURCE_CHANGED` is a client patched partway through the walk, in which case nothing was applied.',
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'SOURCE_CHANGED', 'INCOMPLETE', 'STUCK', 'MALFORMED', 'TOO_LARGE', 'UNAVAILABLE'],
|
||||
},
|
||||
catalog: { type: 'string', nullable: true, example: 'a3f9c21d4b8e0771' },
|
||||
extractorVersion: { type: 'integer', nullable: true, example: 1 },
|
||||
@@ -821,8 +811,8 @@ module.exports = {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
description:
|
||||
'Machine-readable cause. `NO_IMAGING` is a shard host with no libgdiplus. `UNSUPPORTED` is a plugin overlay that serves the creature catalogue but not item art — update the overlay.',
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'NO_IMAGING', 'UNSUPPORTED', 'INCOMPLETE', 'STUCK', 'MALFORMED', 'TOO_LARGE', 'UNAVAILABLE'],
|
||||
'Machine-readable cause. `UNSUPPORTED` is a plugin overlay that serves the creature catalogue but not item art — update the overlay.',
|
||||
enum: ['DISABLED', 'NO_SOURCE', 'SHARD_DOWN', 'PROTOCOL', 'BUSY', 'UNSUPPORTED', 'INCOMPLETE', 'STUCK', 'MALFORMED', 'TOO_LARGE', 'UNAVAILABLE'],
|
||||
},
|
||||
catalog: {
|
||||
type: 'string',
|
||||
|
||||
@@ -107,7 +107,6 @@ const sourcesReply = (extra = {}) =>
|
||||
ok({
|
||||
kind: 'assets.sources.ok',
|
||||
extractorVersion: 1,
|
||||
imaging: { ok: true },
|
||||
hashing: false,
|
||||
complete: true,
|
||||
files: [
|
||||
@@ -334,16 +333,16 @@ test('a busy shard is retried rather than failing the walk', async (t) => {
|
||||
assert.equal(assets.size, 1)
|
||||
})
|
||||
|
||||
test('a shard host with no libgdiplus is named, not reported as a dead shard', async (t) => {
|
||||
test('a 503 is a shard that is down, whatever its reason says', async (t) => {
|
||||
saved.getAssetManifest = uoLinkClient.getAssetManifest
|
||||
t.after(restore)
|
||||
|
||||
uoLinkClient.getAssetManifest = async () =>
|
||||
fail(503, { reason: "this shard host cannot render images - Mono's System.Drawing needs libgdiplus" })
|
||||
fail(503, { reason: 'the shard is not connected' })
|
||||
|
||||
await assert.rejects(
|
||||
() => bridge.readManifest(),
|
||||
(err) => err.code === 'NO_IMAGING',
|
||||
(err) => err.code === 'SHARD_DOWN',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ const sourcesReply = (file = {}) =>
|
||||
ok({
|
||||
kind: 'assets.sources.ok',
|
||||
extractorVersion: 1,
|
||||
imaging: { ok: true },
|
||||
hashing: false,
|
||||
complete: true,
|
||||
files: [
|
||||
|
||||
@@ -61,7 +61,6 @@ function stubEverything({ manifest, fetched, held = new Map(), meta = null, sour
|
||||
extractorVersion: 1,
|
||||
hashing: false,
|
||||
complete: true,
|
||||
imaging: { ok: true },
|
||||
}
|
||||
|
||||
bridge.readManifest = async () => manifest
|
||||
@@ -162,7 +161,6 @@ test('unchanged client files import nothing at all', async (t) => {
|
||||
extractorVersion: 1,
|
||||
hashing: false,
|
||||
complete: true,
|
||||
imaging: { ok: true },
|
||||
}
|
||||
|
||||
stubEverything({ manifest: manifestOf([]), meta: { sources }, sources })
|
||||
@@ -177,27 +175,6 @@ test('unchanged client files import nothing at all', async (t) => {
|
||||
assert.equal(result.status, 'unchanged')
|
||||
})
|
||||
|
||||
test('a host that cannot render images is named rather than walked', async (t) => {
|
||||
// §4.4: reported on the SOURCE gate, so an operator meets it while setting the
|
||||
// shard up rather than from an empty bestiary weeks later.
|
||||
stubEverything({
|
||||
manifest: manifestOf([]),
|
||||
sources: {
|
||||
files: {},
|
||||
extractorVersion: 1,
|
||||
hashing: false,
|
||||
complete: true,
|
||||
imaging: { ok: false, code: 'NO_IMAGING', reason: 'needs libgdiplus' },
|
||||
},
|
||||
})
|
||||
t.after(restore)
|
||||
|
||||
const result = await model.importAssets()
|
||||
|
||||
assert.equal(result.status, 'unavailable')
|
||||
assert.equal(result.code, 'NO_IMAGING')
|
||||
})
|
||||
|
||||
// ── the diff (§6) ─────────────────────────────────────────────────────────
|
||||
|
||||
test('only the keys whose hash moved are fetched', async (t) => {
|
||||
|
||||
@@ -60,7 +60,6 @@ function stub({
|
||||
extractorVersion: 2,
|
||||
hashing: false,
|
||||
complete: true,
|
||||
imaging: { ok: true },
|
||||
families,
|
||||
})
|
||||
|
||||
@@ -178,25 +177,6 @@ test('no shard link is skipped, not failed', async (t) => {
|
||||
assert.equal((await model.warm()).status, 'skipped')
|
||||
})
|
||||
|
||||
test('a host that cannot render images is the named NO_IMAGING state', async (t) => {
|
||||
stub()
|
||||
t.after(restore)
|
||||
|
||||
bridge.sourceFingerprint = async () => ({
|
||||
files: {},
|
||||
extractorVersion: 2,
|
||||
hashing: false,
|
||||
complete: true,
|
||||
imaging: { ok: false, reason: 'libgdiplus is not installed' },
|
||||
families: ['body', 'static'],
|
||||
})
|
||||
|
||||
const result = await model.warm()
|
||||
|
||||
assert.equal(result.status, 'unavailable')
|
||||
assert.equal(result.code, 'NO_IMAGING')
|
||||
})
|
||||
|
||||
// ── what gets asked for ────────────────────────────────────────────────────
|
||||
|
||||
test('only the keys we do not already hold under the shard’s current catalogue are fetched', async (t) => {
|
||||
|
||||
@@ -317,7 +317,6 @@ test('a tree-only shard tells the client-file readers so, rather than looking em
|
||||
extractorVersion: 3,
|
||||
assetsEnabled: false,
|
||||
treeEnabled: true,
|
||||
imaging: { ok: true },
|
||||
families: ['tree'],
|
||||
files: [],
|
||||
more: false,
|
||||
|
||||
@@ -118,11 +118,7 @@ function describeFailure(res, what) {
|
||||
'BUSY',
|
||||
)
|
||||
case 503:
|
||||
// The named `NO_IMAGING` outcome arrives this way: a Linux shard host with
|
||||
// no libgdiplus cannot render a sprite at all, and §4.4 requires that be an
|
||||
// actionable sentence rather than a stack trace. The shard's own wording
|
||||
// already names the package and the command, so it is passed through.
|
||||
return new AssetBridgeError(reason, /libgdiplus/i.test(reason) ? 'NO_IMAGING' : 'SHARD_DOWN')
|
||||
return new AssetBridgeError(reason, 'SHARD_DOWN')
|
||||
case 504:
|
||||
return new AssetBridgeError(`The shard did not answer: ${reason}`, 'SHARD_DOWN')
|
||||
default:
|
||||
@@ -214,7 +210,7 @@ const SOURCE_FILES = [
|
||||
* Stage 1 of the import gate (§6): have the client files this family reads
|
||||
* changed at all?
|
||||
*
|
||||
* Returns `{ files, extractorVersion, hashing, complete, imaging }` where `files`
|
||||
* Returns `{ files, extractorVersion, hashing, complete, families }` where `files`
|
||||
* is a `{ name: { size, mtime, sha256 } }` map over `SOURCE_FILES` — a file the
|
||||
* shard does not have is simply absent, which is normal (few clients carry all
|
||||
* five anim files).
|
||||
@@ -260,7 +256,6 @@ async function sourceFingerprint() {
|
||||
extractorVersion: Number(res.data?.extractorVersion) || 0,
|
||||
hashing: Boolean(res.data?.hashing),
|
||||
complete: Boolean(res.data?.complete),
|
||||
imaging: res.data?.imaging ?? null,
|
||||
// Which §5 key families this overlay can be asked for (phase 5). Absent on a
|
||||
// phase-3 or phase-4 overlay, which served bodies and nothing else — so the
|
||||
// fallback is `['body']` rather than `[]`: an older shard is not a shard with
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
"Admin · Shard"
|
||||
],
|
||||
"summary": "Client asset import status: what is loaded, what the shard has, whether they differ (admin only)",
|
||||
"description": "What the site currently holds (the imported body catalogue, how many sprites are stored, how many atlas creatures resolved to a body id) beside what the shard reports for the client files those pictures come from. `drift: true` means the client files have changed since the last import — press Import. `shard.hashing: true` means a null hash is “not computed yet”, not “changed”: the shard hashes 195 MB anim files off the request path. `shard.imaging.ok: false` is the named NO_IMAGING state — a Linux shard host without libgdiplus cannot render a sprite at all, and the reason names the package to install. A shard with no link configured, or one that is down, is a reported state with a reason rather than an error.",
|
||||
"description": "What the site currently holds (the imported body catalogue, how many sprites are stored, how many atlas creatures resolved to a body id) beside what the shard reports for the client files those pictures come from. `drift: true` means the client files have changed since the last import — press Import. `shard.hashing: true` means a null hash is “not computed yet”, not “changed”: the shard hashes 195 MB anim files off the request path. A shard with no link configured, or one that is down, is a reported state with a reason rather than an error.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Asset import status",
|
||||
@@ -9007,68 +9007,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"imaging": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "object"
|
||||
},
|
||||
"nullable": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"example": "Whether the shard host can render an image at all. `ok: false` is the named NO_IMAGING state: ServUO under Mono needs libgdiplus, and without it a Linux shard cannot decode a sprite. Cliloc and atlas import are unaffected."
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "boolean"
|
||||
},
|
||||
"example": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"code": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "string"
|
||||
},
|
||||
"nullable": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
},
|
||||
"example": {}
|
||||
}
|
||||
},
|
||||
"reason": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "string"
|
||||
},
|
||||
"nullable": {
|
||||
"type": "boolean",
|
||||
"example": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"families": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -9167,7 +9105,6 @@
|
||||
"SHARD_DOWN",
|
||||
"PROTOCOL",
|
||||
"BUSY",
|
||||
"NO_IMAGING",
|
||||
"SOURCE_CHANGED",
|
||||
"UNAVAILABLE"
|
||||
],
|
||||
@@ -9190,7 +9127,7 @@
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"example": "Outcome of an asset import. Reported rather than thrown, so a shard that is down or a host that cannot render images is an answer and not a 500."
|
||||
"example": "Outcome of an asset import. Reported rather than thrown, so a shard that is down is an answer and not a 500."
|
||||
},
|
||||
"properties": {
|
||||
"type": "object",
|
||||
@@ -9252,7 +9189,7 @@
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"example": "Machine-readable cause. `NO_IMAGING` is a shard host with no libgdiplus; `SOURCE_CHANGED` is a client patched partway through the walk, in which case nothing was applied."
|
||||
"example": "Machine-readable cause. `SOURCE_CHANGED` is a client patched partway through the walk, in which case nothing was applied."
|
||||
},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
@@ -9262,7 +9199,6 @@
|
||||
"SHARD_DOWN",
|
||||
"PROTOCOL",
|
||||
"BUSY",
|
||||
"NO_IMAGING",
|
||||
"SOURCE_CHANGED",
|
||||
"INCOMPLETE",
|
||||
"STUCK",
|
||||
@@ -9906,7 +9842,7 @@
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"example": "Machine-readable cause. `NO_IMAGING` is a shard host with no libgdiplus. `UNSUPPORTED` is a plugin overlay that serves the creature catalogue but not item art — update the overlay."
|
||||
"example": "Machine-readable cause. `UNSUPPORTED` is a plugin overlay that serves the creature catalogue but not item art — update the overlay."
|
||||
},
|
||||
"enum": {
|
||||
"type": "array",
|
||||
@@ -9916,7 +9852,6 @@
|
||||
"SHARD_DOWN",
|
||||
"PROTOCOL",
|
||||
"BUSY",
|
||||
"NO_IMAGING",
|
||||
"UNSUPPORTED",
|
||||
"INCOMPLETE",
|
||||
"STUCK",
|
||||
|
||||
Reference in New Issue
Block a user