* ops: build the web app in the Evo deploy and add a preview-capable stack unit The Evo deploy restarted the dev stack without ever building the web app, so a broken production build went unnoticed and the server could not serve the build at all. Service workers and web push also need the production web app behind HTTPS, which the deploy notes did not cover. deploy.sh now builds the web app after install into a staging directory and swaps it into apps/web/dist right before the restart, so a failing build stops the deploy before migrations and the restart and never touches the build a running vite preview serves. Any failure after the checkout rolls back the code, reinstalls, regenerates the client, rebuilds the web app when this deploy had already replaced it, restarts and health-checks; the outcome is recorded as rolled-back or rollback-failed. The health check now fails when the API check fails even if the web check passes. Build output goes to a log that is printed only on failure. start-stack.sh runs api, worker and sandbox supervisor as pnpm dev does and serves the web app either from the Vite dev server (default) or from the build with vite preview on the same port (EVO_WEB_MODE=preview). Preview mode first checks that a build exists and that RAKAZO_HOST and SCREEN_PROXY_SECRET resolve the way vite.config.ts resolves them, using the same secret guard. evoo-local.service is a user unit template for it; the README documents installing it, switching modes, the catalog caveat for production builds, and HTTPS through Caddy with EXTRA_TRUSTED_ORIGINS. A testkit test runs the real scripts against fixture checkouts with fake pnpm, curl and restart hooks. It replaces the unwired shell regression test, which exercised a copy of the SHA capture rather than deploy.sh itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u * ops: show the build error instead of stack frames when a deploy build fails A failing web build printed the last 40 lines of its log, which for a syntax error are mostly bundler stack frames below the message that names the file and line. Drop the frames before printing the tail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u * test: look up the home main conversation in the scheduling journey Since every project has its own main conversation, the journey that schedules for a specialist found the user's main conversation with findFirst over all of them. With the Lab project's conversation also matching, it picked either one, so the check failed about one run in three. The lookup now names the home space, where the specialist joined and the routine is created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u --------- Co-authored-by: Claude <noreply@anthropic.com>
80 lines
2.7 KiB
Bash
Executable File
80 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# evOo-local — start the stack from this checkout (used by evoo-local.service).
|
|
# api, worker and sandbox supervisor run as `pnpm dev` runs them. The web app runs as the Vite dev
|
|
# server (EVO_WEB_MODE=dev, the default) or serves the production build with `vite preview` on the
|
|
# same port (EVO_WEB_MODE=preview). `--check` validates the configuration and exits.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
EVO_WEB_MODE="${EVO_WEB_MODE:-dev}"
|
|
|
|
log() { printf '[evo-stack] %s\n' "$*" >&2; }
|
|
die() { log "ERROR: $*"; exit 1; }
|
|
|
|
# `vite preview` runs with NODE_ENV=production, so apps/web/vite.config.ts refuses development
|
|
# secrets. Resolve the env the way that config does (process env first, then the root .env files)
|
|
# and run the same guard, so a missing value fails here instead of inside a restart loop.
|
|
check_preview() {
|
|
[[ -f "$ROOT/apps/web/dist/index.html" ]] ||
|
|
die "apps/web/dist has no build; run: pnpm --filter @rakazo/web build"
|
|
(cd "$ROOT/apps/web" && NODE_ENV=production "$ROOT/node_modules/.bin/tsx" --input-type=module -e '
|
|
import { loadEnv } from "vite";
|
|
import { resolveScreenProxySecret } from "../../packages/core/src/secrets-guard.ts";
|
|
|
|
const files = loadEnv("production", "../..", "");
|
|
const env = { ...process.env };
|
|
for (const key of ["RAKAZO_HOST", "SCREEN_PROXY_SECRET", "SANDBOX_SUPERVISOR_TOKEN", "BETTER_AUTH_SECRET"]) {
|
|
env[key] = files[key];
|
|
}
|
|
const problems = [];
|
|
if (!env.RAKAZO_HOST?.trim()) problems.push("Set RAKAZO_HOST to the hostname the web app is served on.");
|
|
try {
|
|
resolveScreenProxySecret(env);
|
|
} catch (error) {
|
|
problems.push(error.message);
|
|
}
|
|
for (const problem of problems) console.error("[evo-stack] ERROR: " + problem);
|
|
process.exitCode = problems.length > 0 ? 1 : 0;
|
|
')
|
|
}
|
|
|
|
start_preview() {
|
|
pnpm dev '--filter=!@rakazo/web' &
|
|
SERVICES_PID=$!
|
|
NODE_ENV=production pnpm --filter @rakazo/web preview --strictPort &
|
|
WEB_PID=$!
|
|
trap 'kill "$SERVICES_PID" "$WEB_PID" 2>/dev/null || true' EXIT
|
|
trap 'exit 143' TERM
|
|
trap 'exit 130' INT
|
|
# Polling instead of `wait -n` keeps this working on bash 3.2.
|
|
while kill -0 "$SERVICES_PID" 2>/dev/null && kill -0 "$WEB_PID" 2>/dev/null; do
|
|
sleep 1
|
|
done
|
|
die "a service exited; stopping the stack"
|
|
}
|
|
|
|
main() {
|
|
case "${1:-}" in
|
|
"" | --check) ;;
|
|
*) die "usage: start-stack.sh [--check]" ;;
|
|
esac
|
|
case "$EVO_WEB_MODE" in
|
|
dev | preview) ;;
|
|
*) die "EVO_WEB_MODE must be dev or preview (got: $EVO_WEB_MODE)" ;;
|
|
esac
|
|
cd "$ROOT"
|
|
if [[ "$EVO_WEB_MODE" == preview ]]; then
|
|
check_preview
|
|
fi
|
|
if [[ "${1:-}" == --check ]]; then
|
|
log "ok ($EVO_WEB_MODE)"
|
|
return 0
|
|
fi
|
|
if [[ "$EVO_WEB_MODE" == dev ]]; then
|
|
exec pnpm dev
|
|
fi
|
|
start_preview
|
|
}
|
|
|
|
main "$@"
|