mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 04:07:57 +01:00
Phase 2b browser-verify exposed it: Next's standalone tracer copies node-pty's JS (lib/, package.json) but not its dynamically-loaded build/Release/pty.node, so /api/workspaces 500'd with 'Failed to load native module: pty.node'. The postbuild deploy already copies tracer-missed assets (static/public/content) — node-pty's binary belongs in the same step. Verified: with the binary present, the embedded PTY terminal round-trips end-to-end in the browser (provision + output stream + keystroke input + event-sourced status), zero zellij. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
66 lines
3.3 KiB
Bash
Executable File
66 lines
3.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# deploy-local.sh — runs automatically as the npm postbuild hook.
|
|
#
|
|
# Copies runtime assets into .next/standalone/ (required for the production
|
|
# server to serve CSS, JS chunks, public files, and markdown content) then restarts
|
|
# the fleetcrown-app systemd service if it is installed on this machine.
|
|
# Legacy cockpit-app service name is supported as a fallback for transitional installs.
|
|
#
|
|
# Skips silently in CI or on machines where the service is not installed, so
|
|
# running `npm run build` in GitHub Actions stays clean.
|
|
|
|
set -euo pipefail
|
|
|
|
# Hosted CI (GitHub Actions) must not run the local standalone-copy + systemd
|
|
# restart path — there's no systemd there, so any failure surfaces as a
|
|
# misleading "Command npm run build exited with 1". Skip cleanly when CI is set.
|
|
if [ -n "${CI:-}" ]; then
|
|
echo "→ deploy: CI detected — skipping local standalone+systemd path"
|
|
exit 0
|
|
fi
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
STANDALONE="$PROJECT_DIR/.next/standalone"
|
|
|
|
if [ ! -d "$STANDALONE" ]; then
|
|
# Standalone output not present (e.g. output: "export" override or CI).
|
|
exit 0
|
|
fi
|
|
|
|
# ── Copy runtime assets ───────────────────────────────────────────────────────
|
|
# Next standalone tracing does not include client/static assets or markdown
|
|
# loaded from process.cwd() by server-rendered content routes.
|
|
rm -rf "$STANDALONE/.next/static" "$STANDALONE/public" "$STANDALONE/content"
|
|
cp -r "$PROJECT_DIR/.next/static" "$STANDALONE/.next/static"
|
|
cp -r "$PROJECT_DIR/public" "$STANDALONE/public"
|
|
cp -r "$PROJECT_DIR/content" "$STANDALONE/content"
|
|
echo "→ deploy: runtime assets copied to standalone"
|
|
|
|
# ── node-pty native binary ────────────────────────────────────────────────────
|
|
# node-pty (the LocalPtyExecutor that backs FleetCrown-owned agent PTYs) loads
|
|
# its compiled .node binary dynamically, so Next's file tracer copies the JS
|
|
# (lib/, package.json) into standalone but NOT build/Release/pty.node — the
|
|
# server then 500s with "Failed to load native module: pty.node". Copy the whole
|
|
# build dir alongside it. Same lesson as the assets above. See
|
|
# docs/architecture/agent-execution-platform.md.
|
|
NODE_PTY_SRC="$PROJECT_DIR/node_modules/node-pty/build"
|
|
NODE_PTY_DEST="$STANDALONE/node_modules/node-pty/build"
|
|
if [ -d "$NODE_PTY_SRC" ] && [ -d "$STANDALONE/node_modules/node-pty" ]; then
|
|
rm -rf "$NODE_PTY_DEST"
|
|
cp -r "$NODE_PTY_SRC" "$NODE_PTY_DEST"
|
|
echo "→ deploy: node-pty native binary copied to standalone"
|
|
fi
|
|
|
|
# ── Restart systemd service (local machine only) ──────────────────────────────
|
|
# Prefer the canonical fleetcrown-app service; fall back to legacy cockpit-app
|
|
# for machines still running the pre-rename install.
|
|
for SERVICE in fleetcrown-app cockpit-app; do
|
|
SERVICE_FILE="$HOME/.config/systemd/user/${SERVICE}.service"
|
|
if [ -f "$SERVICE_FILE" ] && systemctl --user is-enabled --quiet "$SERVICE" 2>/dev/null; then
|
|
systemctl --user restart "$SERVICE"
|
|
echo "→ deploy: ${SERVICE} service restarted"
|
|
break
|
|
fi
|
|
done
|