mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 15:28:27 +01:00
The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
74 lines
4.2 KiB
Bash
74 lines
4.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Full-fleet verification sweep: systemd state + public HTTPS for every app
|
|
# in apps.conf plus the four pre-existing services. Exit 1 if anything fails.
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
source "$(dirname "${BASH_SOURCE[0]}")/../_brand.sh" # APP_SLUG / APP_DOMAIN / BRIDGE_DOMAIN
|
|
set +e # we aggregate failures ourselves; set -e from lib.sh aborts the sweep
|
|
|
|
fail=0
|
|
check() { # name domain port
|
|
local name=$1 domain=$2 port=$3 svc state code pub
|
|
svc="$name-app"
|
|
case "$name" in loki-bridge) svc="loki-bridge";; esac
|
|
state=$(box "systemctl is-active $svc" 2>/dev/null | tr -d '[:space:]')
|
|
code=$(box "curl -s -o /dev/null -w '%{http_code}' --max-time 10 http://localhost:$port/" 2>/dev/null | tr -d '[:space:]')
|
|
if [ "$domain" != "-" ]; then
|
|
pub=$(curl -sL -o /dev/null -w '%{http_code}' --max-time 20 "https://${domain%%,*}/" 2>/dev/null)
|
|
else
|
|
pub="n/a"
|
|
fi
|
|
local ok="OK "
|
|
if [ "$state" != "active" ]; then ok="FAIL"; fail=1; fi
|
|
if [ "$pub" != "n/a" ] && [ "$pub" != "200" ]; then ok="FAIL"; fail=1; fi
|
|
printf "%-4s %-22s systemd=%-8s local=%-4s public=%s\n" "$ok" "$name" "$state" "$code" "$pub"
|
|
}
|
|
|
|
# Pre-existing services (handcrafted units).
|
|
# The bridge serves SSE endpoints only — any HTTP answer (even 404 on /)
|
|
# proves liveness, so it gets its own check.
|
|
bridge_state=$(box "systemctl is-active loki-bridge" 2>/dev/null | tr -d '[:space:]')
|
|
bridge_pub=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 "https://${BRIDGE_DOMAIN}/" 2>/dev/null)
|
|
if [ "$bridge_state" = "active" ] && [ "$bridge_pub" != "000" ]; then
|
|
printf "%-4s %-22s systemd=%-8s public=%s (SSE service, 404 on / is normal)\n" "OK " loki-bridge "$bridge_state" "$bridge_pub"
|
|
else
|
|
printf "%-4s %-22s systemd=%-8s public=%s\n" FAIL loki-bridge "$bridge_state" "$bridge_pub"; fail=1
|
|
fi
|
|
check "$APP_SLUG" "$APP_DOMAIN" 4002
|
|
check orangecat orangecat.ch 4003
|
|
check evig evig.orangecat.ch 4004
|
|
|
|
# Manifest apps
|
|
# The trailing `rest` is load-bearing: bash assigns the remainder of the line to
|
|
# the LAST variable, so without it $db reads "-|S-Ink|client-site|live|-|-|-" on
|
|
# every row. Harmless only for as long as this loop keeps ignoring $db — which
|
|
# is precisely the kind of latent trap app_lookup() in lib.sh already documents
|
|
# having been bitten by. Named here rather than left for the next reader.
|
|
while IFS='|' read -r name port domains repo app_dir db rest; do
|
|
case "$name" in \#*|"") continue;; esac
|
|
check "$name" "$domains" "$port"
|
|
done < <(grep -v '^#' "$MANIFEST")
|
|
|
|
# Supabase stack
|
|
sb=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 https://supabase.orangecat.ch/auth/v1/settings -H "apikey: invalid" 2>/dev/null)
|
|
printf "%-4s %-22s public=%s (401/200 expected)\n" "$([ "$sb" = 401 ] || [ "$sb" = 200 ] && echo OK || { echo FAIL; fail=1; })" "supabase-stack" "$sb"
|
|
|
|
# SSE-block guard: the bridge (4001) MUST NOT have `encode` — compression
|
|
# buffers the event stream so the disconnect never fires and presence goes
|
|
# stale. See scripts/hetzner/box-units/Caddyfile.snippet + connection-presence.
|
|
enc=$(box "awk '/bridge\\.orangecat\\.ch/,/^}/' /etc/caddy/Caddyfile 2>/dev/null | grep -c '^[[:space:]]*encode'" 2>/dev/null | tr -d '[:space:]')
|
|
printf "%-4s %-22s %s\n" "$([ "${enc:-1}" = 0 ] && echo 'OK ' || { echo FAIL; fail=1; })" "bridge-sse-no-encode" "encode lines in bridge block: ${enc:-?}"
|
|
|
|
# Restart-window guard: a proxied block without `lb_try_duration` turns every
|
|
# deploy into user-visible 502s, because Caddy gives up the instant the
|
|
# restarting upstream refuses a connection. This was measured at 784 502s in 7
|
|
# days on loki alone, all inside restart windows, and it is invisible
|
|
# without this check — the app is healthy before and after, so nothing else
|
|
# reports it. Covers the two blocks this repo owns in the handcrafted
|
|
# Caddyfile; the rest are generated by sync-infra.sh, which emits the directive.
|
|
for blk in bridge loki; do
|
|
n=$(box "awk '/^${blk}\\.orangecat\\.ch/,/^}/' /etc/caddy/Caddyfile 2>/dev/null | grep -c 'lb_try_duration'" 2>/dev/null | tr -d '[:space:]')
|
|
printf "%-4s %-22s %s\n" "$([ "${n:-0}" -ge 1 ] 2>/dev/null && echo 'OK ' || { echo FAIL; fail=1; })" "${blk}-restart-retry" "lb_try_duration in ${blk} block: ${n:-?}"
|
|
done
|
|
|
|
exit $fail
|