view hg-web/dev.sh @ 279:b3b547563ec7

Add Google connector service and agent wiki Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code. Co-authored-by: Copilot <[email protected]> Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 22:22:36 -0700
parents c5129452493e
children
line wrap: on
line source

#!/usr/bin/env bash
set -euo pipefail

if [[ -n "${RUNFILES_DIR:-}" ]]; then
  source "$RUNFILES_DIR/bazel_tools/tools/bash/runfiles/runfiles.bash"
elif [[ -n "${RUNFILES_MANIFEST_FILE:-}" ]]; then
  runfiles_library="$(
    grep -sm1 '^bazel_tools/tools/bash/runfiles/runfiles.bash ' \
      "$RUNFILES_MANIFEST_FILE" | cut -d' ' -f2-
  )"
  source "$runfiles_library"
elif [[ -d "$0.runfiles" ]]; then
  RUNFILES_DIR="$0.runfiles"
  export RUNFILES_DIR
  source "$RUNFILES_DIR/bazel_tools/tools/bash/runfiles/runfiles.bash"
elif [[ -f "$0.runfiles_manifest" ]]; then
  RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
  export RUNFILES_MANIFEST_FILE
  runfiles_library="$(
    grep -sm1 '^bazel_tools/tools/bash/runfiles/runfiles.bash ' \
      "$RUNFILES_MANIFEST_FILE" | cut -d' ' -f2-
  )"
  source "$runfiles_library"
else
  echo "Bazel runfiles are unavailable." >&2
  exit 1
fi

workspace="${BUILD_WORKSPACE_DIRECTORY:-}"
if [[ -z "$workspace" || ! -d "$workspace/.hg" ]]; then
  echo "Run this target from the Zenbu workspace." >&2
  exit 1
fi

server="$(rlocation _main/hg-web/hg_web_server)"
hg_binary="$(rlocation _main/third_party/mercurial/runtime/bin/hg)"
runfiles_workspace="$(dirname "$(dirname "$server")")"
hg_pid=""
server_pid=""

cleanup() {
  trap - EXIT INT TERM
  for pid in "$server_pid" "$hg_pid"; do
    if [[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null; then
      kill "$pid" 2>/dev/null || true
    fi
  done
  for pid in "$server_pid" "$hg_pid"; do
    if [[ -n "$pid" ]]; then
      wait "$pid" 2>/dev/null || true
    fi
  done
}

trap cleanup EXIT
trap 'exit 130' INT TERM

HGRCPATH= "$hg_binary" \
  --config "web.allow-push=" \
  --config "web.deny-push=*" \
  --repository "$workspace" serve \
  --address 127.0.0.1 \
  --port 4444 \
  --accesslog - \
  --errorlog - &
hg_pid=$!

(
  cd "$runfiles_workspace"
  exec "$server"
) &
server_pid=$!

echo "hg-web: http://127.0.0.1:6970"
echo "Mercurial wire endpoint: http://127.0.0.1:6970/repo"
echo "Press Ctrl-C to stop both servers."

set +e
wait -n "$hg_pid" "$server_pid"
status=$?
set -e
exit "$status"