confluence_web/scripts/run-backend.sh
Artur Mukhamadiev d77b52ae86 integration: contract checks, error mapping, deployment entry points
- tests/integration: frontend served by backend, runtime error mapping,
  backend + real pi image with scripted model/Confluence (shared example,
  variants, failure paths, cancellation/busy gate, isolation canaries,
  HTTP download ownership, 16 MiB prompt round trip), real OpenAI-compatible
  adapter + real image over a scripted transport, real Chrome against the
  real backend with a scripted runtime peer, backend crash/restart
  reconciliation, and an opt-in live model check (marker: live).
- backend: map runtime terminal codes (model_output_limit,
  model_context_exceeded, query_timeout, connectivity_failed) to the
  contract's HTTP statuses; make the artifact 404 body identical for
  no-session, wrong-session, unknown and expired IDs.
- Makefile, scripts/run-backend.sh, deploy/confluence-web.env.example,
  root README for the integrated application; integration pytest marker.
2026-09-14 22:20:34 +03:00

42 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start the Confluence Research backend (serves the frontend on the same origin).
#
# scripts/run-backend.sh [deploy/confluence-web.env]
#
# Loads the env file, checks the runtime image and rootless daemon, then runs a
# single Uvicorn worker bound to CONFLUENCE_WEB_BIND_HOST:PORT (loopback by default).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ENV_FILE="${1:-$ROOT/deploy/confluence-web.env}"
PYTHON="${PYTHON:-$ROOT/.venv/bin/python}"
if [[ ! -f "$ENV_FILE" ]]; then
echo "env file not found: $ENV_FILE (copy deploy/confluence-web.env.example)" >&2
exit 1
fi
set -a
# shellcheck disable=SC1090
. "$ENV_FILE"
set +a
# Resolve a relative frontend directory against the repository root.
if [[ -n "${CONFLUENCE_WEB_FRONTEND_DIST_DIR:-}" && "${CONFLUENCE_WEB_FRONTEND_DIST_DIR}" != /* ]]; then
export CONFLUENCE_WEB_FRONTEND_DIST_DIR="$ROOT/${CONFLUENCE_WEB_FRONTEND_DIST_DIR#./}"
fi
if [[ "${CONFLUENCE_WEB_DEV_MODE:-false}" != "true" ]]; then
if ! docker info --format '{{json .SecurityOptions}}' 2>/dev/null | grep -q rootless; then
echo "rootless Docker daemon is required (docker context use rootless)" >&2
exit 1
fi
if ! docker image inspect "${CONFLUENCE_WEB_RUNTIME_IMAGE:?}" >/dev/null 2>&1; then
echo "runtime image ${CONFLUENCE_WEB_RUNTIME_IMAGE} not found; run: make build-image" >&2
exit 1
fi
fi
exec "$PYTHON" -m uvicorn backend.app:create_app --factory --workers 1 \
--host "${CONFLUENCE_WEB_BIND_HOST:-127.0.0.1}" --port "${CONFLUENCE_WEB_BIND_PORT:-8000}" \
--no-server-header --timeout-keep-alive 5 --limit-concurrency 32 --app-dir "$ROOT"